History log of /haiku/src/add-ons/kernel/drivers/audio/hda/hda_controller.cpp
Revision Date Author Comments
# 629f071b 27-Feb-2024 X512 <danger_mail@list.ru>

pci: extend MSI interrupt vector number to 32 bits

Also increase MSI message data size to 32 bits according to PCIe spec.

Remove 0xff check for MSI interrupts because it is potentially valid
interrupt vector number. Reject 0xff only for legacy pin interrupts.

- MSI-X supports up to 2048 interrupts per device that do not fit to
`uint8`.

- Non-x86 systems may use separate interrupt vector ranges for
hard-wired interrupts and MSI interrupts so `uint8` is not enough to
represent all of them.

Change-Id: Iaf9ffb197ec23db0f97ffe3ea756d28d7bfc8705
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7433
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 3b91d73b 16-Dec-2022 X512 <danger_mail@list.ru>

bus & drivers: drop PCI_x86

Change-Id: I494deaf24a4793a5e0fe9fa46ecdce32f65e616a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6226
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>


# ee457793 06-Oct-2022 Jérôme Duval <jerome.duval@gmail.com>

hda: add missing product entries for newer devices

should fix #17972
update some product entries for intel which requires the skylake quirk
remove product entries for intel which don't require snoop

Change-Id: I08f2bd640fe9bef4405abc9b2eaa83070b9adce9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5719
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 27f95c84 24-May-2022 Augustin Cavalier <waddlesplash@gmail.com>

drivers/audio: Adjust physical memory mapping after recent VM changes.

Fixes more KDLs.


# 956f4507 22-May-2022 Trung Nguyen <trungnt282910@gmail.com>

kernel/vm: Remove default kernel read/write flags

`fix_protection` will not apply `B_KERNEL_READ_AREA` and
`B_KERNEL_WRITE_AREA` by default.

Kernel drivers that directly call `create_area` or `create_area_etc`
and do not pass any protection flags have been updated to
apply `B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA` instead.

Bug: #17751
Change-Id: I43e7ee6b5396e0309cdcff750e28262942c6d01c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5330
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# b50868d0 18-Feb-2022 Jérôme Duval <jerome.duval@gmail.com>

hda: enable power on init

Change-Id: I96b6084a40270aa8007b916a35e54b1fc3b26b39
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4977
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 32f411b9 03-Feb-2022 Jérôme Duval <jerome.duval@gmail.com>

hda: detect some audio devices per device ID

as it's possible they use the audio class_sub instead of hd_audio.
* also power up the audio function, this seems required on Jasper Lake.
* tested on Acer Swift 1 SF114-34.

Change-Id: I603018b1b973e7884aa99a58be1c24e568f2d5ae
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4928
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# a010d38b 19-Jan-2022 Jérôme Duval <jerome.duval@gmail.com>

hda: remove invalid product entries for intel

A few invalid ones were introduced in 2071dc2

Change-Id: Icbe5bb4aafd9d6e03ec4175c10eccdb2e65465d7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4874
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 1286f0cc 23-Sep-2021 Coldfirex <sakison@gmail.com>

hda:sync intel ids list from freebsd

Change-Id: I8a9610a10709de1d54f315d4868b7b4001c06a0f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4500
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>


# 7f276d83 05-Oct-2021 Alexander von Gluck IV <kallisti5@unixzen.com>

hda/intel: disable MISCBDCGE on chip init

* Disabled Misc Backbone Dynamic Clock Gating during init.
* The alsa and linux kernel drivers both do this on
these skylake HD Audio chipsets.
First iteration:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6639484dda
Later iteration (all skylake and broxton):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/pci/hda/hda_intel.c#n555

Change-Id: Id914fb5541f7020b9edb4fa635fcfffde9847663
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4556
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>


# ce534c52 25-Jan-2021 Jérôme Duval <jerome.duval@gmail.com>

hda: disable 64bits dma addressing for some devices

* creative, not supported
* amd/ati/nvidia, supports 40/48bits, disabled for simplicity
* should help with #16491

Change-Id: I736d17b7dc5d4798688f9bd2741705362837b082
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3680
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# d9ff5e56 31-Jul-2020 Michael Lotz <mmlr@mlotz.ch>

hda: Remove interrupt hanlder before freeing interrupt vector.

Freeing an interrupt vector that still has handlers is not allowed.

Change-Id: If2f256e5288c7a61b7e23bdb202f259f5b67b7ae
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3112
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# bfb040f0 22-Jul-2020 Michael Lotz <mmlr@mlotz.ch>

hda: Use B_32_BIT_CONTIGUOUS when controller is not 64 bit.

This ensures that the allocated physical memory uses 32 bit addresses.

Also avoid writing to the 64 bit address registers when the controller
is not 64 bit.

Change-Id: I58008d68bcd9579903534f824db2660f73e39160
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3065
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 71e84ce7 19-Jul-2020 Michael Lotz <mmlr@mlotz.ch>

hda: Style cleanup only, no functional change.

Change-Id: Id36bf67a51369099093ae24412fa681f88c4c8d0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3064
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 07edf62c 19-Jul-2020 Michael Lotz <mmlr@mlotz.ch>

hda: Reset streams before (re-)setting DMA memory addresses.

The spec says that changing the DMA memory addresses of a stream should
really only be done after a reset and before the first run. Stopping the
stream is not enough, as the controller is allowed to cache the
addresses even when the stream is paused.

Note that this is applied to both, the initial configuration of buffers
and to the case of dynamically changing stream parameters. In the initial
case this should always be a no-op as the controller was previously
globally reset.

In the dynamic reconfiguration case this fixes random memory corruption
due to the controller still accessing and modifying physical memory that
is released by the driver. With some controllers, such corruption was
easily triggered by changing the input and output sampling rates for the
HDA device in the media preferences.

The return value of the reset call is intentionally not checked to allow
for it to partially or fully fail. At least for HDA under QEMU, the
stream reset fails to start, while the initial stream stop still works
and prevents the memory corruption.

Change-Id: I7c6e6547ee08889a2990de26d5eed5e73b2ca13c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3063
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# f010a08f 19-Jul-2020 Michael Lotz <mmlr@mlotz.ch>

hda: Make interrupt setup more conservative.

Don't unconditionally enable PCI interrupt generation as this only
applies when MSIs are not in use. Delay the evaluation and setting of
the interrupt disable bit until after it is clear whether or not MSIs
are to be used.

Initially force interrupt generation off as early as possible. Depending
on the initial state of the controller, some spurious interrupts might
come up and we really don't want them to occur before everything is set
up in the right way.

Change-Id: Ifb12f5eef1cbf8ecfa3f352564139125d8ad2169
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3062
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 8d917e95 19-Jul-2020 Michael Lotz <mmlr@mlotz.ch>

hda: Remove doubled and early put of gPCIx86Module.

This is already properly done in uninit_driver.

Putting the module in device instead of driver uninit meant that on a
device reopen the gPCIx86Module would always be gone and therefore MSIs
could not be used anymore even if they previously were.

Change-Id: Ib3bddefbe6bcb02fa1c97f3c843cecaf31c80e3e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3061
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 4ba91f34 19-Jul-2020 Michael Lotz <mmlr@mlotz.ch>

hda: Unconfigure the MSI as well.

Just disabling it will leak the vector reservation and makes it
impossible to configure an MSI on the device again.

Also removes the check for the gPCIx86Module as having an MSI configured
really implies its presence.

Change-Id: I9f0e3e63c988af515d23ad93d86918cde9add97a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3060
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# a95a2065 19-Jul-2020 Michael Lotz <mmlr@mlotz.ch>

hda: Disable MSIs when installing the interrupt handler fails.

This was previously only done if reset failed.

Change-Id: I30ebe1d302087816bccfe67e3d236c9446425aea
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3059
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 3b121627 19-Jul-2020 Michael Lotz <mmlr@mlotz.ch>

hda: Wait for streams to actually start/stop.

In the start case this adds debug output in case a start fails.

For stops this makes sure the stream DMA engine has actually stopped
operating, which is a precondition for some other operations.

Change-Id: I0e2731513febd0e0cd4e1f0ef89cf3d7312a47e1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3058
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# de2e028f 19-Jul-2020 Michael Lotz <mmlr@mlotz.ch>

hda: Factor out waiting for bits to be set/cleared.

It is a recurring pattern to set some bits, then wait for them to be
read as set or the reverse. For resets this is done once in both
directions, so factoring this out removes quite a bit of similar code.

No functional change intended.

Change-Id: I2ae4b6cce490c33e1a027328f01fbffea67c5180
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3057
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 733e150b 11-Jul-2020 Michael Lotz <mmlr@mlotz.ch>

drivers: Fix 64 bit BAR checks and remove redundant masking.

Fix address type mask to use the right bits via PCI_address_type. The
previous 0xc value applies to the upper of the two address type and
the prefetchable bit instead of the two adddress type bits. This would
cause prefetchable 64 bit BARs to be misidentified as not being 64 bit.

Remove address masking as this is already done on the field in pci_info.

Use uint64 instead of phys_addr_t explicitly as on pure 32 bit platforms
this would otherwise result in a shift greater than type size.

Note that the sizes should theoretically be adjusted as well, but in all
of these cases a size needing the upper 32 bits doesn't make much sense.

Change-Id: Idd0d6e9a6cc18656b43cafcac720b132fc1f2ad3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3024
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 532b6aa4 03-Jun-2020 Bruno Albuquerque <bga@bug-br.org.br>

HDA: Fix mapping 64-bit PCI addresses.

Some small cleanup.

Change-Id: I07f6cfeedc9f650740e1be7ab998b4fc3e0fd4d2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2875
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# a5544d0a 28-Feb-2020 Jérôme Duval <jerome.duval@gmail.com>

hda: disable TCSEL on ATI/AMD for non-hmdi

also disable MSI with C-MEDIA 0x5011 (reference alsa)

Change-Id: I51e0b8f046df13a23a0b39998e4155a2ec40f5f2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2290
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 276e89f7 27-Feb-2020 Jérôme Duval <jerome.duval@gmail.com>

hda: sync snoop quirk intel pci ids list based on alsa.

Change-Id: I08d8e8aa05d03ce49cbf3937eccdb109b00e83f2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2288
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 8a1c964d 27-Feb-2020 Jérôme Duval <jerome.duval@gmail.com>

hda: enable pci snooping on AMD non-hdmi.

disable snooping on ATI non-hdmi.

Change-Id: Ic62e8c7ae376a1e26646f88f308242eef3aa119e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2287
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# b4c187b0 30-Nov-2019 Joachim Mairböck <j.mairboeck@gmail.com>

hda: add necessary quirk for SiS Azalia Audio Controller

Fixes #15499.

Change-Id: I8bc6df5770f902b6b43e54d80bcfee4afc42f0bd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1981
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 0c5f4fb7 16-Jul-2019 Adrien Destugues <pulkomandy@pulkomandy.tk>

PVS V595: use before null-check

Change-Id: I1e74b376d77686c08778882b6f2c4c67a51b6eb3
Reviewed-on: https://review.haiku-os.org/c/1614
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>


# 10baa577 09-Mar-2019 Jérôme Duval <jerome.duval@gmail.com>

hda: wait between set and unset of the GLOBAL_CONTROL_RESET bit.

* the spec requires 521us, 1000us is generally used.
* also only uninit streams, corb and rirb when a codec reset is in progress (seen in zircon).
linux instead clears HDAC_STATE_STATUS.


# 8f21fce0 19-Nov-2018 Augustin Cavalier <waddlesplash@gmail.com>

HDA: VirtualBox no longer needs QUIRK_NO_CORBRP_RESET_ACK.


# efd9848f 19-Nov-2018 Augustin Cavalier <waddlesplash@gmail.com>

HDA: VMware's emulated controllers have HDA_QUIRK_NO_CORBRP_RESET_ACK.

On my VMware Player installation, the device ID is "1977", but presumably
VMware will have only one HDA codebase, and so we just enable the fix on
all devices.

This fixes initialization of the HDA driver on VMware, and means that
it is now possible to get sound output on VMware without using the
OpenSound driver package.


# 7848bf79 22-Jul-2018 Jérôme Duval <jerome.duval@gmail.com>

hda: fix 64-bit warnings.


# d20630d0 28-Jun-2018 Jérôme Duval <jerome.duval@gmail.com>

hda: remove a few ids from the quirks snoop list for intel.

should fix #14231. misread from the alsa quirk list.


# 36d62867 19-May-2018 Jérôme Duval <jerome.duval@gmail.com>

hda: sync snoop quirk pci ids list based on alsa.


# 048796e1 03-Apr-2018 Jérôme Duval <jerome.duval@gmail.com>

hda: sync snoop quirk pci ids list based on alsa.


# 0c1281a1 21-Jul-2016 Augustin Cavalier <waddlesplash@gmail.com>

hda: Create HDA_QUIRK_NO_CORBRP_RESET_ACK and use it.

This is instead of just checking for NVIDIA devices. Also add an entry
for Intel 0x2668 (VirtualBox's HDA controller). Gets HDA a bit further
in VirtualBox, but an acquire_sem() times out later on.


# 9457b769 06-Jun-2015 Adrien Destugues <pulkomandy@gmail.com>

hda: cleanup tracing.

* Make sure all traces are prefixed with the driver name (for easier
grepping)
* Remove some useless traces
* 80 column limit fixes


# 08e98ffd 03-Sep-2014 Julian Harnath <julian.harnath@rwth-aachen.de>

Style fix: line length


# 7ef10f89 03-Sep-2014 Julian Harnath <julian.harnath@rwth-aachen.de>

Relaxed CORB read pointer reset checking for nVidia HDA

* At least some nVidia HDA controllers do not acknowledge the CORB
read pointer reset, which is required by the spec (cf. HDA 1.0a
ch. 3.3.21). For these controllers, do not fail when acknowledge
is missing.

* Makes hda driver work for nVidia HDA controllers again, thus fixing
the regression pointed out in #10212.


# ec8fc5ee 02-Sep-2014 Julian Harnath <julian.harnath@rwth-aachen.de>

Use uncached memory areas if snooping is not possible

* Some chipsets do not support bus-snooping for the HDA data
transfers. So, when trying to enable snooping, verify that the
setting was accepted.

* When snooping is not possible, set memory areas for audio buffers,
buffer descriptor lists and command ring-buffers as uncached to
ensure memory coherency with the HDA controller.

* This fixes KDLs during booting on some systems where snooping
is not supported (seen on two systems with AMD chipsets, maybe
applies to others as well).
After setting up the buffer descriptor list for a stream, it was a
gamble whether these writes would be visible to the HDA controller
when subsequently enabling the stream. On some boots it was unlucky
and then the HDA controller's DMA engine would go haywire and start
overwriting random kernel memory with audio input data. The
scheduler was usually the first victim and caused page fault KDLs
due to corrupted data structures.


# 84dfba29 01-Sep-2014 Julian Harnath <julian.harnath@rwth-aachen.de>

Preserve reserved bits in registers

* Do read-modify-write cycle to preserve bits marked as RsvdP in the
following registers: WAKEEN, CORBWP, CORBCTL, CORBSIZE, RIRBWP,
RINTCNT, RIRBCTL, RIRBSIZE.


# 2d498c88 01-Sep-2014 Julian Harnath <julian.harnath@rwth-aachen.de>

Use correct sequence for resetting CORB read pointer

* Spec requires software to wait for hardware to acknowledge the
reset by waiting for the bit to become set and then manually
unset it and again wait for it to become unset.
(cf. HDA spec 1.0a ch. 3.3.21)

* Also, do read-modify-write to protect preserved bits


# 78b950bd 01-Sep-2014 Julian Harnath <julian.harnath@rwth-aachen.de>

Read back CORB/RIRB control register to ensure DMA has stopped

* Spec is somewhat unclear about whether that is really necessary,
but let's play safe.


# f196b1a6 01-Jun-2014 Jérôme Duval <jerome.duval@gmail.com>

hda: add snoop quirk for a few other pci ids.

* based on alsa.


# 45e3a5ed 30-May-2014 Murai Takashi <tmurai01@gmail.com>

hda: Add Baytrail HDA controller

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>


# 51b735b3 01-Sep-2013 Jérôme Duval <jerome.duval@gmail.com>

hdaudio: enable MSI support

* disabled for nVidia and Creative Technology devices.


# 75384e60 19-Nov-2012 Marcus Overhagen <marcus@overhagen.de>

Enable PCI memory access and interrupt


# 25a627d8 12-Nov-2012 Jerome Duval <jerome.duval@gmail.com>

hda: fixes KDL on HDMI, some digital quirks

* avoid crashing in case of lack of playback or record stream
* set format on digital output widgets
* accept digital output on the output path


# 0a361580 05-Nov-2012 Axel Dörfler <axeld@pinc-software.de>

Added HDA quirks for enabling snoop.

* Enabled snoop for all Intel hardware as found in the Linux driver.
* This fixes #8949.


# de62b051 05-Nov-2012 Axel Dörfler <axeld@pinc-software.de>

Disabled HDA MSI for now again.

* At least on my hardware, audio becomes a bit flaky (ie. sometimes it would
just stop doing anything at all).


# 225c8cc5 01-Oct-2012 Axel Dörfler <axeld@pinc-software.de>

Minor cleanup, no functional change.


# 41828f15 23-Sep-2012 Axel Dörfler <axeld@pinc-software.de>

Cleanup, no functional change intended.


# 25b89454 23-Sep-2012 Axel Dörfler <axeld@pinc-software.de>

MSI interrupts were not disabled on error.


# 19559d24 23-Sep-2012 Axel Dörfler <axeld@pinc-software.de>

Reset controller::active_codec on uninit.

* The controller structure is static, so if you closed the device,
and the driver failed to initialize correctly (ie. finds no codec)
on the second try, it would have crashed accessing an already freed
codec.
* Not sure why it fails to detect any codecs on second open, yet,
though.


# 45732903 20-Sep-2012 Axel Dörfler <axeld@pinc-software.de>

Implemented MSI support.

* Does not seem to change anything, though (I'm also a victim of bug
#8949)
* Minor cleanup.


# c95f35ce 09-Aug-2012 Axel Dörfler <axeld@pinc-software.de>

Fixed 64 bit issue for the buffer descriptor base.


# c356b047 08-May-2011 Jérôme Duval <korli@users.berlios.de>

spaces -> tab


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41388 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 882d595f 27-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* If an unknown type is encountered, return immediately. This fixes CID 1504.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38408 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b14ae02b 12-Jun-2010 Jérôme Duval <korli@users.berlios.de>

some verbs use a 16 bits payload


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37114 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9a0a4979 12-Jun-2010 Jérôme Duval <korli@users.berlios.de>

* add some helper functions to read/write verbs.
* try at support realtek alc888. alsa uses this init sequence.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37113 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 64d79eff 27-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed physical_entry::{address,size} to phys_{addr,size}_t and changed
map_physical_memory()'s physicalAddress parameter type from void* to
phys_addr_t. This breaks source compatibility, but -- as long as
phys_{addr,size}_t remain 32 bit wide -- keeps binary compatibility with
BeOS.
* Adjusted all code using the affected interfaces (Oh what fun!). Added a few
TODOs in places where the wrong types (e.g. void* for physical addresses
are used). Looks like quite a few drivers aren't 64 bit safe and others
will break with PAE.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36960 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e25dcf1a 15-Jan-2010 Jérôme Duval <korli@users.berlios.de>

* We now mute internal speakers when using headphones. We don't distinguish between headphones and mic jacks though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35088 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dfb72c78 21-Dec-2009 Jérôme Duval <korli@users.berlios.de>

* warn_count is unused.
* the last valid index should be written in HDAC_STREAM_LAST_VALID instead of the fragment count.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34730 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f887c705 16-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Try to detect whether the stream's DMA position is broken and switch to using
the LPIB, if it is.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34684 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e0a187dd 15-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* stream_handle_interrupt():
- Round the DMA position for the buffer cycle computation. Apparently some
chipsets trigger the interrupt before the position has been updated.
- Don't just assume that stream->buffer_length frames have been processed
at that time. Use the exact stream position at that time. This makes the
performance time computation more precise and immune to the interrupt
being delayed.
* Init hda_stream::frames_count.

Audio skips on I/O seem to be gone for me, now. Not obviously motivated skips
still happen.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34671 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4673f145 14-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* stream_handle_interrupt(): Fixed a misunderstanding of the SDnLPIB (stream
descriptor n link position in buffer) registers. They contain "the number
of bytes that have been received off the link", which is not to be confused
with the number of bytes that have been transferred by the DMA engine.
The interrupt is triggered when the last byte of the buffer has been fetched
by the DMA engine, at which point the stream's LPIB is still somewhere in
the last buffer. So the interrupt handler could compute the wrong buffer
index, which would lead to the multi audio add-on filling the wrong
(currently being transferred) buffer, resulting in noisy sound. Now we use
the DMA position. Should fix #4072.
* Also removed the not (always) working hack-around for the "wrong" buffer
positions in the interrupt handler.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34664 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 59967f76 11-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* buffer_ready_sem was released with B_DO_NOT_RESCHEDULE, but without
returning B_INVOKE_SCHEDULER from the interrupt handler, causing
latencies up to a full quantum for the multi audio output thread. This
change improves audio clicks quite a bit on my machine. Though they still
happen from time to time and particulary on FS activity.
* Automatic whitespace cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34633 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4aafe92a 29-Nov-2009 Jérôme Duval <korli@users.berlios.de>

* cleanup
* use gpio count for gpio quirks


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34355 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 144c4c62 29-Nov-2009 Jérôme Duval <korli@users.berlios.de>

* added vref and unsol responses definitions
* untested unsolicited response support
* added quirk support for vref and gpio
* vref are now enabled for all inputs, and gpio for some Apple Macs
* replaced dprintf with TRACE and ERROR macros


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34352 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8c393635 13-Sep-2009 Jérôme Duval <korli@users.berlios.de>

* prints the stream fifo size


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33121 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ea9f99f3 10-Sep-2009 Jérôme Duval <korli@users.berlios.de>

try to align the offset to be more compliant


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33047 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 561c00c9 10-Sep-2009 Jérôme Duval <korli@users.berlios.de>

prints out stream status errors


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33046 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1cab92ad 08-Sep-2009 Jérôme Duval <korli@users.berlios.de>

try at workaround early playback interrupts on non intel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33011 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e21d1251 03-Sep-2009 Jérôme Duval <korli@users.berlios.de>

the flag means no snoop


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32924 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1f5d96af 21-Aug-2009 Jérôme Duval <korli@users.berlios.de>

we now print a warning message in the log when the interrupt comes in the second half of a buffer: this should mean the interrupt comes earlier than expected.
Please report such warnings, they can help to investigate timing issues with some hda codecs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32589 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d936f5e3 28-Jul-2009 Jérôme Duval <korli@users.berlios.de>

* now uses only one buffer_ready semaphore, this way the buffer exchange is done asap, useful when rates/formats are different between playback and record.
* checked what offsets my hardware my hardware really had: it affected only playback, and was 192 for 16 bits and 256 for 20/24 bits. With these values, playback and record are crystal clear.
As I can't find any references for such offset values anywhere, sorry it's not supposed to work out of the box on all hardware. Maybe we could adjust the offset at runtime.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31875 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 94aabcd3 11-May-2009 Stephan Aßmus <superstippi@gmx.de>

* Fix by Cyan: Do the offset calculation taking the rate base into account.
Fixes using the HDA driver with frame rates based on 44100Hz.
* Automatic white space cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30704 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0bd93b7d 07-Mar-2009 Stephan Aßmus <superstippi@gmx.de>

* Use a default buffer frame count that is adapted to the sample rate
of the audio group. This is supposed to keep the latency about the same
regardless of sample rate and lessen the requirements on the system
performance when using higher sample rates. Currently the multi-audio
addon uses the highest available rate.
* Added TODO about the highest sample rate seemingly being forgotten in one
place.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29421 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b5aca78a 26-Feb-2009 Jérôme Duval <korli@users.berlios.de>

* compute offset based on vendor (32 for non intel) and sample rate


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29327 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 346ae57c 25-Feb-2009 Jérôme Duval <korli@users.berlios.de>

* Stream interrupts seem to arrive too early on most HDA chips:
we adjust buffer descriptors to take this into account. It defaults to one sample, but it should depend also on the sample rate or the chip vendor.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29322 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a6809d0e 09-Feb-2009 Ithamar R. Adema <ithamar.adema@team-embedded.nl>

Do not enable interrupts on codec status change, since we do not handle those. This fixes the lockup on the EeePC, and follows the description in the HDA specs.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29172 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6dec91b4 15-Jan-2009 Jérôme Duval <korli@users.berlios.de>

use uint32 as temp variable, noticed by Marcus. Thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28914 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 391bf22d 14-Jan-2009 Jérôme Duval <korli@users.berlios.de>

try to complete snooping enablement


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28906 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 74010f99 06-Jan-2009 Jérôme Duval <korli@users.berlios.de>

* reading CORB_READ_POS_RESET as zero fails on some chips (ie nForce).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28849 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c71a6614 01-Jan-2009 Jérôme Duval <korli@users.berlios.de>

* try to enable EAPD on capable pin widgets
* added a pin capabilities attribute instead of input and output pin attributes
* added ATI and nVidia vendor ids definitions
* uses "mic in" and "line in" when pin colors are undefined


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28839 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 321e633f 01-Jan-2009 Jérôme Duval <korli@users.berlios.de>

Patch from tqh, modified by myself: enable PCIe snooping through vendor specific registers (ATI and nVidia).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28838 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 311781df 19-Nov-2008 Jérôme Duval <korli@users.berlios.de>

* uses the default output stream on all audio outputs (and all output paths)
* enable trace to debug mixer controls build


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28699 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8c3da8dd 16-Nov-2008 Jérôme Duval <korli@users.berlios.de>

added a mixer interface


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28677 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1fb04337 12-Aug-2008 Jérôme Duval <korli@users.berlios.de>

* added pin capabilities and power support constants
* added a record stream, assigned it to input widgets: no recorded sound yet, though buffer cycling is ok


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26953 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b0884f0c 07-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed a ton of wrong usages of B_CONTIGUOUS + B_FULL_LOCK.
* The use of B_{READ|WRITE}_AREA throughout the drivers is surely alarming.
Defining these flags means that *every user* application can access these
buffers read/write, it becomes visible in userspace like any other memory
(just shared among all apps). I would like to ask each driver maintainer
to see if that is really wished here. If you only need one app to be able
to access it, cloning the area would be more appropriate.
* I came across the use of B_ANY_KERNEL_BLOCK_ADDRESS a number of times. This
is almost completely useless for most usages, as it tries to align the
virtual to a multiple of the size of the area. It just makes the allocation
more likely to fail. Please only use where appropriate, and please review
your code.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26858 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1708513c 06-Aug-2008 Jérôme Duval <korli@users.berlios.de>

* added an ALIGN macro for easing readability and use it for 128 alignments
* use HDAC_STREAM_POSITION register value to check the current buffer cycle in interrupt handler
* added B_FULL_LOCK flags for area allocation, not sure it's handled but at least more correct
* buffer descriptors now use a low and high address fields
* applied a byte mask on format
* enabled PCI bus mastering if not yet done
* the PCI space register TCSEL (Traffic Class Select Register, which sets PCI express QOS) is now reset to TC0 (clear 0-2 bits) as needed on some boards like mine to
ensure good playback

Playback is finally working correctly here on ICH8 HDA!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26847 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 06688259 16-Jul-2008 Jérôme Duval <korli@users.berlios.de>

fix alignment


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26446 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3787196a 08-Jul-2008 Jérôme Duval <korli@users.berlios.de>

* some methods to access stream registers were defined with wrong types
* use HDAC_BIDIR_STREAM_OFFSET and HDAC_OUTPUT_STREAM_OFFSET when applicable
* use a PAGE_ALIGN macro


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26330 a95241bf-73f2-0310-859d-f6bbb57e9c96


# df709516 06-Jul-2008 Jérôme Duval <korli@users.berlios.de>

moved stateStatus read/write out of the interrupt handler
added some error verbose


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26282 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a9410600 07-May-2008 Axel Dörfler <axeld@pinc-software.de>

* Rewrote controller reset - it now performs a full reset, and does no longer
assume the driver to be in reset when started.
* Major cleanup of the register access: now hda_controller and hda_stream both
have member functions for this, the OREGx() and REGx() macros are gone.
* Made the register names and definitions more descriptive - the short names
of the specs are still mentioned in the comments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25352 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 30f55bc9 12-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Rewrote widget output path discovery, it's now very similar to what the
FreeBSD driver is doing.
* hda_codec_new_audio_group() did not free the audio group's widgets on
failure.
* No longer create the input stream for now.
* Reworked multiaudio-support to work regardless if there is only a playback
or record stream.
* With these changes, I hear nothing on my laptop anymore (before there was
noise), but on another system, I can finally hear something that sounds very
much like the sinus wave the multi_audio_test application produces; the
sound quality is pretty bad though (lots of periodical noise and glitches).
* Made B_MULTI_GET_DESCRIPTION safe to be called from userland.
* Minor other cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24383 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 438500b02 29-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

A bit more meaningful constant names.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24183 a95241bf-73f2-0310-859d-f6bbb57e9c96


# abf12dd8 29-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* Shuffled the functions a bit around to separate private from public functions.
* Renamed some functions, added comments.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24182 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c6073952 29-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

Accidently read one response less than needed since reworking it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24181 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 340dd4fe 29-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

Renamed .c to .cpp, and fixed all warnings.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24178 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9457b76963e6c42507bc913a4e77dd78cbce7c38 06-Jun-2015 Adrien Destugues <pulkomandy@gmail.com>

hda: cleanup tracing.

* Make sure all traces are prefixed with the driver name (for easier
grepping)
* Remove some useless traces
* 80 column limit fixes


# 08e98ffde1d253bd55cec08785204071440f2039 03-Sep-2014 Julian Harnath <julian.harnath@rwth-aachen.de>

Style fix: line length


# 7ef10f899a2ea6484a3e72c457e26e7d510f6fe4 03-Sep-2014 Julian Harnath <julian.harnath@rwth-aachen.de>

Relaxed CORB read pointer reset checking for nVidia HDA

* At least some nVidia HDA controllers do not acknowledge the CORB
read pointer reset, which is required by the spec (cf. HDA 1.0a
ch. 3.3.21). For these controllers, do not fail when acknowledge
is missing.

* Makes hda driver work for nVidia HDA controllers again, thus fixing
the regression pointed out in #10212.


# ec8fc5ee39bac3272d3223f8bc66ff5bb48bfd92 02-Sep-2014 Julian Harnath <julian.harnath@rwth-aachen.de>

Use uncached memory areas if snooping is not possible

* Some chipsets do not support bus-snooping for the HDA data
transfers. So, when trying to enable snooping, verify that the
setting was accepted.

* When snooping is not possible, set memory areas for audio buffers,
buffer descriptor lists and command ring-buffers as uncached to
ensure memory coherency with the HDA controller.

* This fixes KDLs during booting on some systems where snooping
is not supported (seen on two systems with AMD chipsets, maybe
applies to others as well).
After setting up the buffer descriptor list for a stream, it was a
gamble whether these writes would be visible to the HDA controller
when subsequently enabling the stream. On some boots it was unlucky
and then the HDA controller's DMA engine would go haywire and start
overwriting random kernel memory with audio input data. The
scheduler was usually the first victim and caused page fault KDLs
due to corrupted data structures.


# 84dfba29725224ef05391486cd983eaa8d5466da 01-Sep-2014 Julian Harnath <julian.harnath@rwth-aachen.de>

Preserve reserved bits in registers

* Do read-modify-write cycle to preserve bits marked as RsvdP in the
following registers: WAKEEN, CORBWP, CORBCTL, CORBSIZE, RIRBWP,
RINTCNT, RIRBCTL, RIRBSIZE.


# 2d498c889c489534c879ad4d682dc98dbd18ed7d 01-Sep-2014 Julian Harnath <julian.harnath@rwth-aachen.de>

Use correct sequence for resetting CORB read pointer

* Spec requires software to wait for hardware to acknowledge the
reset by waiting for the bit to become set and then manually
unset it and again wait for it to become unset.
(cf. HDA spec 1.0a ch. 3.3.21)

* Also, do read-modify-write to protect preserved bits


# 78b950bd2d3fa49931a0b242d6c6e8e54ade1567 01-Sep-2014 Julian Harnath <julian.harnath@rwth-aachen.de>

Read back CORB/RIRB control register to ensure DMA has stopped

* Spec is somewhat unclear about whether that is really necessary,
but let's play safe.


# f196b1a6626ee2354e018d2627bafc763b14dc9a 01-Jun-2014 Jérôme Duval <jerome.duval@gmail.com>

hda: add snoop quirk for a few other pci ids.

* based on alsa.


# 45e3a5edae1df5b0d2792c5df5a8e15883583ce6 30-May-2014 Murai Takashi <tmurai01@gmail.com>

hda: Add Baytrail HDA controller

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>


# 51b735b342238e43cac59bb01f1654f57d6681fc 01-Sep-2013 Jérôme Duval <jerome.duval@gmail.com>

hdaudio: enable MSI support

* disabled for nVidia and Creative Technology devices.


# 75384e609293eebaaf9c60dc5c2690bc6e95d74a 19-Nov-2012 Marcus Overhagen <marcus@overhagen.de>

Enable PCI memory access and interrupt


# 25a627d8800361c42b1f29bd2f2d29b323e9cc2d 12-Nov-2012 Jerome Duval <jerome.duval@gmail.com>

hda: fixes KDL on HDMI, some digital quirks

* avoid crashing in case of lack of playback or record stream
* set format on digital output widgets
* accept digital output on the output path


# 0a361580ad81fd49bdb887656e0c934a73020fb4 05-Nov-2012 Axel Dörfler <axeld@pinc-software.de>

Added HDA quirks for enabling snoop.

* Enabled snoop for all Intel hardware as found in the Linux driver.
* This fixes #8949.


# de62b051e4f059d8ebe04e4df7e64afa03f4626a 05-Nov-2012 Axel Dörfler <axeld@pinc-software.de>

Disabled HDA MSI for now again.

* At least on my hardware, audio becomes a bit flaky (ie. sometimes it would
just stop doing anything at all).


# 225c8cc59aac7901a84ca8baf9957037b31e62fb 01-Oct-2012 Axel Dörfler <axeld@pinc-software.de>

Minor cleanup, no functional change.


# 41828f1567c91a86ebcfb331f556e222dd9364c4 23-Sep-2012 Axel Dörfler <axeld@pinc-software.de>

Cleanup, no functional change intended.


# 25b89454c4a36470e48f0bc2d1e179391dd1a4dc 23-Sep-2012 Axel Dörfler <axeld@pinc-software.de>

MSI interrupts were not disabled on error.


# 19559d24fc23d18bdabfba839e5198f7f55537d8 23-Sep-2012 Axel Dörfler <axeld@pinc-software.de>

Reset controller::active_codec on uninit.

* The controller structure is static, so if you closed the device,
and the driver failed to initialize correctly (ie. finds no codec)
on the second try, it would have crashed accessing an already freed
codec.
* Not sure why it fails to detect any codecs on second open, yet,
though.


# 45732903d07ccec4eec384d839327f47b1321912 20-Sep-2012 Axel Dörfler <axeld@pinc-software.de>

Implemented MSI support.

* Does not seem to change anything, though (I'm also a victim of bug
#8949)
* Minor cleanup.


# c95f35ce9de5f9e8ed86142b19beca3ce6cc3eea 09-Aug-2012 Axel Dörfler <axeld@pinc-software.de>

Fixed 64 bit issue for the buffer descriptor base.


# c356b0477f343fd3942cc521d4823b041d829f8d 08-May-2011 Jérôme Duval <korli@users.berlios.de>

spaces -> tab


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41388 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 882d595fc0dc1a80ac9b69ac149fb814c2526d27 27-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* If an unknown type is encountered, return immediately. This fixes CID 1504.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38408 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b14ae02b959b3dd6f1d681515c445e71df725042 12-Jun-2010 Jérôme Duval <korli@users.berlios.de>

some verbs use a 16 bits payload


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37114 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9a0a4979d5dad3a3689e2f8420abec40fdbd2a91 12-Jun-2010 Jérôme Duval <korli@users.berlios.de>

* add some helper functions to read/write verbs.
* try at support realtek alc888. alsa uses this init sequence.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37113 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 64d79eff7290437d24b1a420537c3ed5c144ab96 27-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed physical_entry::{address,size} to phys_{addr,size}_t and changed
map_physical_memory()'s physicalAddress parameter type from void* to
phys_addr_t. This breaks source compatibility, but -- as long as
phys_{addr,size}_t remain 32 bit wide -- keeps binary compatibility with
BeOS.
* Adjusted all code using the affected interfaces (Oh what fun!). Added a few
TODOs in places where the wrong types (e.g. void* for physical addresses
are used). Looks like quite a few drivers aren't 64 bit safe and others
will break with PAE.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36960 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e25dcf1a96e0fcadf6ce67afae010f6d5e601acf 15-Jan-2010 Jérôme Duval <korli@users.berlios.de>

* We now mute internal speakers when using headphones. We don't distinguish between headphones and mic jacks though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35088 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dfb72c7888dc9f25d5868e7698c67706c5705fcb 21-Dec-2009 Jérôme Duval <korli@users.berlios.de>

* warn_count is unused.
* the last valid index should be written in HDAC_STREAM_LAST_VALID instead of the fragment count.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34730 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f887c7059e3604ec8d9bfe77e29f97f0d31fdffe 16-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Try to detect whether the stream's DMA position is broken and switch to using
the LPIB, if it is.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34684 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e0a187dd5931a6bf829ea306f80d28c2a4e3cff9 15-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* stream_handle_interrupt():
- Round the DMA position for the buffer cycle computation. Apparently some
chipsets trigger the interrupt before the position has been updated.
- Don't just assume that stream->buffer_length frames have been processed
at that time. Use the exact stream position at that time. This makes the
performance time computation more precise and immune to the interrupt
being delayed.
* Init hda_stream::frames_count.

Audio skips on I/O seem to be gone for me, now. Not obviously motivated skips
still happen.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34671 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4673f145a3c583f903dcc913786131ff99b55bf5 14-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* stream_handle_interrupt(): Fixed a misunderstanding of the SDnLPIB (stream
descriptor n link position in buffer) registers. They contain "the number
of bytes that have been received off the link", which is not to be confused
with the number of bytes that have been transferred by the DMA engine.
The interrupt is triggered when the last byte of the buffer has been fetched
by the DMA engine, at which point the stream's LPIB is still somewhere in
the last buffer. So the interrupt handler could compute the wrong buffer
index, which would lead to the multi audio add-on filling the wrong
(currently being transferred) buffer, resulting in noisy sound. Now we use
the DMA position. Should fix #4072.
* Also removed the not (always) working hack-around for the "wrong" buffer
positions in the interrupt handler.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34664 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 59967f764e0535767d6b24a0613baadf2ed22576 11-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* buffer_ready_sem was released with B_DO_NOT_RESCHEDULE, but without
returning B_INVOKE_SCHEDULER from the interrupt handler, causing
latencies up to a full quantum for the multi audio output thread. This
change improves audio clicks quite a bit on my machine. Though they still
happen from time to time and particulary on FS activity.
* Automatic whitespace cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34633 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4aafe92a0e65a2d8ae667548be97a1af72c17abb 29-Nov-2009 Jérôme Duval <korli@users.berlios.de>

* cleanup
* use gpio count for gpio quirks


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34355 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 144c4c6240d02385fc69fe159ecdd253641da0a1 29-Nov-2009 Jérôme Duval <korli@users.berlios.de>

* added vref and unsol responses definitions
* untested unsolicited response support
* added quirk support for vref and gpio
* vref are now enabled for all inputs, and gpio for some Apple Macs
* replaced dprintf with TRACE and ERROR macros


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34352 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8c393635e2790a8d2b57a0f2c71efc004d9147bb 13-Sep-2009 Jérôme Duval <korli@users.berlios.de>

* prints the stream fifo size


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33121 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ea9f99f3fb20c068154164ce98740ba55e26ea79 10-Sep-2009 Jérôme Duval <korli@users.berlios.de>

try to align the offset to be more compliant


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33047 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 561c00c9c352564be3581f89be59f10a93c28b1e 10-Sep-2009 Jérôme Duval <korli@users.berlios.de>

prints out stream status errors


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33046 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1cab92ade6d17a408324d89ba2375f175bf27641 08-Sep-2009 Jérôme Duval <korli@users.berlios.de>

try at workaround early playback interrupts on non intel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33011 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e21d12516e8d23ac4a4f7205c461ab9ed3d7adf7 03-Sep-2009 Jérôme Duval <korli@users.berlios.de>

the flag means no snoop


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32924 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1f5d96afb85daf74cabf5eb517d56ff408ddc266 21-Aug-2009 Jérôme Duval <korli@users.berlios.de>

we now print a warning message in the log when the interrupt comes in the second half of a buffer: this should mean the interrupt comes earlier than expected.
Please report such warnings, they can help to investigate timing issues with some hda codecs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32589 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d936f5e31fa2e40a9da45dd4e129153a82b75d0b 28-Jul-2009 Jérôme Duval <korli@users.berlios.de>

* now uses only one buffer_ready semaphore, this way the buffer exchange is done asap, useful when rates/formats are different between playback and record.
* checked what offsets my hardware my hardware really had: it affected only playback, and was 192 for 16 bits and 256 for 20/24 bits. With these values, playback and record are crystal clear.
As I can't find any references for such offset values anywhere, sorry it's not supposed to work out of the box on all hardware. Maybe we could adjust the offset at runtime.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31875 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 94aabcd3938659e201d0ce7bd7c5285354d6143a 11-May-2009 Stephan Aßmus <superstippi@gmx.de>

* Fix by Cyan: Do the offset calculation taking the rate base into account.
Fixes using the HDA driver with frame rates based on 44100Hz.
* Automatic white space cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30704 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0bd93b7def8c10073f2cec8dad5caeb844acdb78 07-Mar-2009 Stephan Aßmus <superstippi@gmx.de>

* Use a default buffer frame count that is adapted to the sample rate
of the audio group. This is supposed to keep the latency about the same
regardless of sample rate and lessen the requirements on the system
performance when using higher sample rates. Currently the multi-audio
addon uses the highest available rate.
* Added TODO about the highest sample rate seemingly being forgotten in one
place.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29421 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b5aca78a043568c5a67b2735331c818ad3313e76 26-Feb-2009 Jérôme Duval <korli@users.berlios.de>

* compute offset based on vendor (32 for non intel) and sample rate


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29327 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 346ae57c93770205d30dd33ed621411c231ccce1 25-Feb-2009 Jérôme Duval <korli@users.berlios.de>

* Stream interrupts seem to arrive too early on most HDA chips:
we adjust buffer descriptors to take this into account. It defaults to one sample, but it should depend also on the sample rate or the chip vendor.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29322 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a6809d0e5c0aee0c2eebd4687a62761db2e1de34 09-Feb-2009 Ithamar R. Adema <ithamar.adema@team-embedded.nl>

Do not enable interrupts on codec status change, since we do not handle those. This fixes the lockup on the EeePC, and follows the description in the HDA specs.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29172 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6dec91b4e818c263876e9e5e2c239a2988013311 15-Jan-2009 Jérôme Duval <korli@users.berlios.de>

use uint32 as temp variable, noticed by Marcus. Thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28914 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 391bf22d7945a894afb034e4ccb61fc2b8d151d4 14-Jan-2009 Jérôme Duval <korli@users.berlios.de>

try to complete snooping enablement


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28906 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 74010f99115a5276a6e475084070893a8a2f9c5a 06-Jan-2009 Jérôme Duval <korli@users.berlios.de>

* reading CORB_READ_POS_RESET as zero fails on some chips (ie nForce).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28849 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c71a6614e2c46e35d1796191c8fb04d9fb1071b0 01-Jan-2009 Jérôme Duval <korli@users.berlios.de>

* try to enable EAPD on capable pin widgets
* added a pin capabilities attribute instead of input and output pin attributes
* added ATI and nVidia vendor ids definitions
* uses "mic in" and "line in" when pin colors are undefined


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28839 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 321e633fa4b8e858a4bbe9b4de35074a818f99da 01-Jan-2009 Jérôme Duval <korli@users.berlios.de>

Patch from tqh, modified by myself: enable PCIe snooping through vendor specific registers (ATI and nVidia).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28838 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 311781dfcccd26454182b1c3ab10467fa05e7e5e 19-Nov-2008 Jérôme Duval <korli@users.berlios.de>

* uses the default output stream on all audio outputs (and all output paths)
* enable trace to debug mixer controls build


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28699 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8c3da8dd2ca2427d7efa609ef8708bdf7d07da92 16-Nov-2008 Jérôme Duval <korli@users.berlios.de>

added a mixer interface


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28677 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1fb04337f500f048d6c43fd8398ef3bf6c420eec 12-Aug-2008 Jérôme Duval <korli@users.berlios.de>

* added pin capabilities and power support constants
* added a record stream, assigned it to input widgets: no recorded sound yet, though buffer cycling is ok


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26953 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b0884f0cb812cdaf8035e6028f69dcf0d7721953 07-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed a ton of wrong usages of B_CONTIGUOUS + B_FULL_LOCK.
* The use of B_{READ|WRITE}_AREA throughout the drivers is surely alarming.
Defining these flags means that *every user* application can access these
buffers read/write, it becomes visible in userspace like any other memory
(just shared among all apps). I would like to ask each driver maintainer
to see if that is really wished here. If you only need one app to be able
to access it, cloning the area would be more appropriate.
* I came across the use of B_ANY_KERNEL_BLOCK_ADDRESS a number of times. This
is almost completely useless for most usages, as it tries to align the
virtual to a multiple of the size of the area. It just makes the allocation
more likely to fail. Please only use where appropriate, and please review
your code.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26858 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1708513ca8a6aca38dd653cd6a982ed4fbb286c0 06-Aug-2008 Jérôme Duval <korli@users.berlios.de>

* added an ALIGN macro for easing readability and use it for 128 alignments
* use HDAC_STREAM_POSITION register value to check the current buffer cycle in interrupt handler
* added B_FULL_LOCK flags for area allocation, not sure it's handled but at least more correct
* buffer descriptors now use a low and high address fields
* applied a byte mask on format
* enabled PCI bus mastering if not yet done
* the PCI space register TCSEL (Traffic Class Select Register, which sets PCI express QOS) is now reset to TC0 (clear 0-2 bits) as needed on some boards like mine to
ensure good playback

Playback is finally working correctly here on ICH8 HDA!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26847 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 06688259b6950a886fc3fe760ba10729df085a8e 16-Jul-2008 Jérôme Duval <korli@users.berlios.de>

fix alignment


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26446 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3787196a5a32fc32657a90a062c7d5dc56d2fbd0 08-Jul-2008 Jérôme Duval <korli@users.berlios.de>

* some methods to access stream registers were defined with wrong types
* use HDAC_BIDIR_STREAM_OFFSET and HDAC_OUTPUT_STREAM_OFFSET when applicable
* use a PAGE_ALIGN macro


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26330 a95241bf-73f2-0310-859d-f6bbb57e9c96


# df709516a049ef767e69aacba9878e03649178b3 06-Jul-2008 Jérôme Duval <korli@users.berlios.de>

moved stateStatus read/write out of the interrupt handler
added some error verbose


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26282 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a9410600271a751844bc99f643977479d591c07d 07-May-2008 Axel Dörfler <axeld@pinc-software.de>

* Rewrote controller reset - it now performs a full reset, and does no longer
assume the driver to be in reset when started.
* Major cleanup of the register access: now hda_controller and hda_stream both
have member functions for this, the OREGx() and REGx() macros are gone.
* Made the register names and definitions more descriptive - the short names
of the specs are still mentioned in the comments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25352 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 30f55bc9908b08803b0fdd7f9f10e3a9f132a63f 12-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Rewrote widget output path discovery, it's now very similar to what the
FreeBSD driver is doing.
* hda_codec_new_audio_group() did not free the audio group's widgets on
failure.
* No longer create the input stream for now.
* Reworked multiaudio-support to work regardless if there is only a playback
or record stream.
* With these changes, I hear nothing on my laptop anymore (before there was
noise), but on another system, I can finally hear something that sounds very
much like the sinus wave the multi_audio_test application produces; the
sound quality is pretty bad though (lots of periodical noise and glitches).
* Made B_MULTI_GET_DESCRIPTION safe to be called from userland.
* Minor other cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24383 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 438500b022361f076e1766b41edfc9d24d89bc70 29-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

A bit more meaningful constant names.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24183 a95241bf-73f2-0310-859d-f6bbb57e9c96


# abf12dd83fb8a4e1e4f4df7ce91d85a99dcd08b2 29-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* Shuffled the functions a bit around to separate private from public functions.
* Renamed some functions, added comments.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24182 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c607395208f6b82aedd99bd3df3f391532e5b258 29-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

Accidently read one response less than needed since reworking it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24181 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 340dd4fe3db4608f82f8cd3599d1fe0117233afa 29-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

Renamed .c to .cpp, and fixed all warnings.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24178 a95241bf-73f2-0310-859d-f6bbb57e9c96