DevIchIntelHDA.cpp revision 48a5358f2f99d054c9b6a1a0f063c11c9addfe14
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync/* $Id$ */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync/** @file
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync * DevIchIntelHD - VBox ICH Intel HD Audio Controller.
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync/*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * Copyright (C) 2006-2010 Oracle Corporation
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync *
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * available from http://www.virtualbox.org. This file is free software;
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * you can redistribute it and/or modify it under the terms of the GNU
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * General Public License (GPL) as published by the Free Software
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync/*******************************************************************************
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync* Header Files *
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync*******************************************************************************/
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#define LOG_GROUP LOG_GROUP_DEV_AUDIO
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync#include <VBox/pdmdev.h>
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync#include <iprt/assert.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include <iprt/uuid.h>
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include <iprt/string.h>
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include <iprt/mem.h>
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include <iprt/asm.h>
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include "../Builtins.h"
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsyncextern "C" {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include "audio.h"
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync}
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include "DevCodec.h"
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#undef LOG_VOICES
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#ifndef VBOX
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync//#define USE_MIXER
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync#else
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#define USE_MIXER
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#endif
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#define VBOX_WITH_INTEL_HDA
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define HDA_SSM_VERSION 1
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncPDMBOTHCBDECL(int) hdaMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncPDMBOTHCBDECL(int) hdaMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsyncstatic DECLCALLBACK(void) hdaReset (PPDMDEVINS pDevIns);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync/* Registers */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define HDA_REG_IND_NAME(x) ICH6_HDA_REG_##x
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define HDA_REG_FIELD_NAME(reg, x) ICH6_HDA_##reg##_##x
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define HDA_REG_FIELD_MASK(reg, x) ICH6_HDA_##reg##_##x##_MASK
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define HDA_REG_FIELD_FLAG_MASK(reg, x) RT_BIT(ICH6_HDA_##reg##_##x##_SHIFT)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define HDA_REG_FIELD_SHIFT(reg, x) ICH6_HDA_##reg##_##x##_SHIFT
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define HDA_REG_IND(pState, x) ((pState)->au32Regs[(x)])
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define HDA_REG(pState, x) (HDA_REG_IND((pState), HDA_REG_IND_NAME(x)))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define HDA_REG_VALUE(pState, reg, val) (HDA_REG((pState),reg) & (((HDA_REG_FIELD_MASK(reg, val))) << (HDA_REG_FIELD_SHIFT(reg, val))))
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#define HDA_REG_FLAG_VALUE(pState, reg, val) (HDA_REG((pState),reg) & (((HDA_REG_FIELD_FLAG_MASK(reg, val)))))
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define HDA_REG_SVALUE(pState, reg, val) (HDA_REG_VALUE(pState, reg, val) >> (HDA_REG_FIELD_SHIFT(reg, val)))
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync#define ICH6_HDA_REG_GCAP 0 /* range 0x00-0x01*/
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#define GCAP(pState) (HDA_REG((pState), GCAP))
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#define ICH6_HDA_REG_VMIN 1 /* range 0x02 */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#define VMIN(pState) (HDA_REG((pState), VMIN))
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#define ICH6_HDA_REG_VMAJ 2 /* range 0x03 */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#define VMAJ(pState) (HDA_REG((pState), VMAJ))
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync#define ICH6_HDA_REG_OUTPAY 3 /* range 0x04-0x05 */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define OUTPAY(pState) (HDA_REG((pState), OUTPAY))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#define ICH6_HDA_REG_INPAY 4 /* range 0x06-0x07 */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define INPAY(pState) (HDA_REG((pState), INPAY))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_REG_GCTL (5)
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync#define ICH6_HDA_GCTL_RST_SHIFT (0)
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync#define ICH6_HDA_GCTL_FSH_SHIFT (1)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define ICH6_HDA_GCTL_UR_SHIFT (8)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define GCTL(pState) (HDA_REG((pState), GCTL))
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_WAKEEN 6 /* 0x0C */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define WAKEEN(pState) (HDA_REG((pState), WAKEEN))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_REG_STATESTS 7 /* range 0x0E */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#define STATESTS(pState) (HDA_REG((pState), STATESTS))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_STATES_SCSF 0x7
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_REG_GSTS 8 /* range 0x10-0x11*/
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_GSTS_FSH_SHIFT (1)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define GSTS(pState) (HDA_REG(pState, GSTS))
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#define ICH6_HDA_REG_INTCTL 9 /* 0x20 */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#define ICH6_HDA_INTCTL_GIE_SHIFT 31
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define ICH6_HDA_INTCTL_CIE_SHIFT 30
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define ICH6_HDA_INTCTL_S0_SHIFT (0)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define ICH6_HDA_INTCTL_S1_SHIFT (1)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define ICH6_HDA_INTCTL_S2_SHIFT (2)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define ICH6_HDA_INTCTL_S3_SHIFT (3)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define ICH6_HDA_INTCTL_S4_SHIFT (4)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_INTCTL_S5_SHIFT (5)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_INTCTL_S6_SHIFT (6)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_INTCTL_S7_SHIFT (7)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define INTCTL(pState) (HDA_REG((pState), INTCTL))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define INTCTL_GIE(pState) (HDA_REG_FLAG_VALUE(pState, INTCTL, GIE))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define INTCTL_CIE(pState) (HDA_REG_FLAG_VALUE(pState, INTCTL, CIE))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define INTCTL_SX(pState, X) (HDA_REG_FLAG_VALUE((pState), INTCTL, S##X))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define INTCTL_SALL(pState) (INTCTL((pState)) & 0xFF)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync/* Note: The HDA specification defines a SSYNC register at offset 0x38. The
0c94a8282c9042b02f022302a3d987746140eab9vboxsync * ICH6/ICH9 datahseet defines SSYNC at offset 0x34. The Linux HDA driver matches
0c94a8282c9042b02f022302a3d987746140eab9vboxsync * the datasheet.
0c94a8282c9042b02f022302a3d987746140eab9vboxsync */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_REG_SSYNC 12 /* 0x34 */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define SSYNC(pState) (HDA_REG((pState), SSYNC))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_REG_INTSTS 10 /* 0x24 */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_INTSTS_GIS_SHIFT (31)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_INTSTS_CIS_SHIFT (30)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_INTSTS_S0_SHIFT (0)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_INTSTS_S1_SHIFT (1)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_INTSTS_S2_SHIFT (2)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_INTSTS_S3_SHIFT (3)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_INTSTS_S4_SHIFT (4)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_INTSTS_S5_SHIFT (5)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_INTSTS_S6_SHIFT (6)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_INTSTS_S7_SHIFT (7)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_INTSTS_S_MASK(num) RT_BIT(HDA_REG_FIELD_SHIFT(S##num))
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync#define INTSTS(pState) (HDA_REG((pState), INTSTS))
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#define INTSTS_GIS(pState) (HDA_REG_FLAG_VALUE((pState), INTSTS, GIS)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#define INTSTS_CIS(pState) (HDA_REG_FLAG_VALUE((pState), INTSTS, CIS)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync#define INTSTS_SX(pState, X) (HDA_REG_FLAG_VALUE(pState), INTSTS, S##X)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define INTSTS_SANY(pState) (INTSTS((pState)) & 0xFF)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_REG_CORBLBASE 13 /* 0x40 */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define CORBLBASE(pState) (HDA_REG((pState), CORBLBASE))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_REG_CORBUBASE 14 /* 0x44 */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define CORBUBASE(pState) (HDA_REG((pState), CORBUBASE))
56970d3a1944c7c073d66266cd52449835221badvboxsync#define ICH6_HDA_REG_CORBWP 15 /* 48 */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_REG_CORBRP 16 /* 4A */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_CORBRP_RST_SHIFT 15
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#define ICH6_HDA_CORBRP_WP_SHIFT 0
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#define ICH6_HDA_CORBRP_WP_MASK 0xFF
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
56970d3a1944c7c073d66266cd52449835221badvboxsync#define CORBRP(pState) (HDA_REG(pState, CORBRP))
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync#define CORBWP(pState) (HDA_REG(pState, CORBWP))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_REG_CORBCTL 17 /* 0x4C */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_CORBCTL_DMA_SHIFT (1)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_CORBCTL_CMEIE_SHIFT (0)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define CORBCTL(pState) (HDA_REG(pState, CORBCTL))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_REG_CORBSTS 18 /* 0x4D */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define CORBSTS(pState) (HDA_REG(pState, CORBSTS))
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define ICH6_HDA_CORBSTS_CMEI_SHIFT (0)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_REG_CORBSIZE 19 /* 0x4E */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_CORBSIZE_SZ_CAP 0xF0
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_CORBSIZE_SZ 0x3
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define CORBSIZE_SZ(pState) (HDA_REG(pState, ICH6_HDA_REG_CORBSIZE) & ICH6_HDA_CORBSIZE_SZ)
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define CORBSIZE_SZ_CAP(pState) (HDA_REG(pState, ICH6_HDA_REG_CORBSIZE) & ICH6_HDA_CORBSIZE_SZ_CAP)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync/* till ich 10 sizes of CORB and RIRB are harcoded to 256 in real hw */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync#define ICH6_HDA_REG_RIRLBASE 20 /* 0x50 */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define RIRLBASE(pState) (HDA_REG((pState), RIRLBASE))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define ICH6_HDA_REG_RIRUBASE 21 /* 0x54 */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define RIRUBASE(pState) (HDA_REG((pState), RIRUBASE))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync#define ICH6_HDA_REG_RIRBWP 22 /* 0x58 */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_RIRBWP_RST_SHIFT (15)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_RIRBWP_WP_MASK 0xFF
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define RIRBWP(pState) (HDA_REG(pState, RIRBWP))
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define ICH6_HDA_REG_RINTCNT 23 /* 0x5A */
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define RINTCNT(pState) (HDA_REG((pState), RINTCNT))
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define RINTCNT_N(pState) (RINTCNT((pState)) & 0xff)
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define ICH6_HDA_REG_RIRBCTL 24 /* 0x5C */
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define ICH6_HDA_RIRBCTL_RIC_SHIFT (0)
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define ICH6_HDA_RIRBCTL_DMA_SHIFT (1)
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define ICH6_HDA_ROI_DMA_SHIFT (2)
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define RIRBCTL(pState) (HDA_REG((pState), RIRBCTL))
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define RIRBCTL_RIRB_RIC(pState) (HDA_REG_FLAG_VALUE(pState, RIRBCTL, RIC))
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define RIRBCTL_RIRB_DMA(pState) (HDA_REG_FLAG_VALUE((pState), RIRBCTL, DMA)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define RIRBCTL_ROI(pState) (HDA_REG_FLAG_VALUE((pState), RIRBCTL, ROI))
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_RIRBSTS 25 /* 0x5D */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_RIRBSTS_RINTFL_SHIFT (0)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_RIRBSTS_RIRBOIS_SHIFT (2)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define RIRBSTS(pState) (HDA_REG(pState, RIRBSTS))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define RIRBSTS_RINTFL(pState) (HDA_REG_FLAG_VALUE(pState, RIRBSTS, RINTFL))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define RIRBSTS_RIRBOIS(pState) (HDA_REG_FLAG_VALUE(pState, RIRBSTS, RIRBOIS))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
1969e98a26e5b56b67fbe3b6bfa007f8f09e86ebvboxsync#define ICH6_HDA_REG_RIRBSIZE 26 /* 0x5E */
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync#define ICH6_HDA_RIRBSIZE_SZ_CAP 0xF0
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync#define ICH6_HDA_RIRBSIZE_SZ 0x3
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define RIRBSIZE_SZ(pState) (HDA_REG(pState, ICH6_HDA_REG_RIRBSIZE) & ICH6_HDA_RIRBSIZE_SZ)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define RIRBSIZE_SZ_CAP(pState) (HDA_REG(pState, ICH6_HDA_REG_RIRBSIZE) & ICH6_HDA_RIRBSIZE_SZ_CAP)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_REG_IC 27 /* 0x60 */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define IC(pState) (HDA_REG(pState, IC))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_REG_IR 28 /* 0x64 */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define IR(pState) (HDA_REG(pState, IR))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_REG_IRS 29 /* 0x68 */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_IRS_ICB_SHIFT (0)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_IRS_IRV_SHIFT (1)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define IRS(pState) (HDA_REG(pState, IRS))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define IRS_ICB(pState) (HDA_REG_FLAG_VALUE(pState, IRS, ICB))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define IRS_IRV(pState) (HDA_REG_FLAG_VALUE(pState, IRS, IRV))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_REG_DPLBASE 30 /* 0x70 */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define DPLBASE(pState) (HDA_REG((pState), DPLBASE))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_REG_DPUBASE 31 /* 0x74 */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define DPUBASE(pState) (HDA_REG((pState), DPUBASE))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define DPBASE_ENABLED 1
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define DPBASE_ADDR_MASK (~0x7f)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define HDA_STREAM_REG_DEF(name, num) (ICH6_HDA_REG_SD##num##name)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define HDA_STREAM_REG(pState, name, num) (HDA_REG((pState), N_(HDA_STREAM_REG_DEF(name, num))))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_REG_SD0CTL 32 /* 0x80 */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_REG_SD1CTL (HDA_STREAM_REG_DEF(CTL, 0) + 10) /* 0xA0 */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_REG_SD2CTL (HDA_STREAM_REG_DEF(CTL, 0) + 20) /* 0xC0 */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_REG_SD3CTL (HDA_STREAM_REG_DEF(CTL, 0) + 30) /* 0xE0 */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_REG_SD4CTL (HDA_STREAM_REG_DEF(CTL, 0) + 40) /* 0x100 */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_REG_SD5CTL (HDA_STREAM_REG_DEF(CTL, 0) + 50) /* 0x120 */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_REG_SD6CTL (HDA_STREAM_REG_DEF(CTL, 0) + 60) /* 0x140 */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDA_REG_SD7CTL (HDA_STREAM_REG_DEF(CTL, 0) + 70) /* 0x160 */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define SD(func, num) SD##num##func
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define SDCTL(pState, num) HDA_REG((pState), SD(CTL, num))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define SDCTL_NUM(pState, num) ((SDCTL((pState), num) & HDA_REG_FIELD_MASK(SDCTL,NUM)) >> HDA_REG_FIELD_SHIFT(SDCTL, NUM))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_SDCTL_NUM_MASK (0xF)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_SDCTL_NUM_SHIFT (20)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_SDCTL_DEIE_SHIFT (4)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_SDCTL_FEIE_SHIFT (3)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_SDCTL_ICE_SHIFT (2)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_SDCTL_RUN_SHIFT (1)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_SDCTL_SRST_SHIFT (0)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD0STS 33 /* 0x83 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD1STS (HDA_STREAM_REG_DEF(STS, 0) + 10) /* 0xA3 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD2STS (HDA_STREAM_REG_DEF(STS, 0) + 20) /* 0xC3 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD3STS (HDA_STREAM_REG_DEF(STS, 0) + 30) /* 0xE3 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD4STS (HDA_STREAM_REG_DEF(STS, 0) + 40) /* 0x103 */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#define ICH6_HDA_REG_SD5STS (HDA_STREAM_REG_DEF(STS, 0) + 50) /* 0x123 */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#define ICH6_HDA_REG_SD6STS (HDA_STREAM_REG_DEF(STS, 0) + 60) /* 0x143 */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#define ICH6_HDA_REG_SD7STS (HDA_STREAM_REG_DEF(STS, 0) + 70) /* 0x163 */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#define SDSTS(pState, num) HDA_REG((pState), SD(STS, num))
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#define ICH6_HDA_SDSTS_FIFORDY_SHIFT (5)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#define ICH6_HDA_SDSTS_DE_SHIFT (4)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_SDSTS_FE_SHIFT (3)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_SDSTS_BCIS_SHIFT (2)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD0LPIB 34 /* 0x84 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD1LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 10) /* 0xA4 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD2LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 20) /* 0xC4 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD3LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 30) /* 0xE4 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD4LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 40) /* 0x104 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD5LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 50) /* 0x124 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD6LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 60) /* 0x144 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD7LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 70) /* 0x164 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define SDLPIB(pState, num) HDA_REG((pState), SD(LPIB, num))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD0CBL 35 /* 0x88 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD1CBL (HDA_STREAM_REG_DEF(CBL, 0) + 10) /* 0xA8 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD2CBL (HDA_STREAM_REG_DEF(CBL, 0) + 20) /* 0xC8 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD3CBL (HDA_STREAM_REG_DEF(CBL, 0) + 30) /* 0xE8 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD4CBL (HDA_STREAM_REG_DEF(CBL, 0) + 40) /* 0x108 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD5CBL (HDA_STREAM_REG_DEF(CBL, 0) + 50) /* 0x128 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD6CBL (HDA_STREAM_REG_DEF(CBL, 0) + 60) /* 0x148 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD7CBL (HDA_STREAM_REG_DEF(CBL, 0) + 70) /* 0x168 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define SDLCBL(pState, num) HDA_REG((pState), SD(CBL, num))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD0LVI 36 /* 0x8C */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD1LVI (HDA_STREAM_REG_DEF(LVI, 0) + 10) /* 0xAC */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD2LVI (HDA_STREAM_REG_DEF(LVI, 0) + 20) /* 0xCC */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD3LVI (HDA_STREAM_REG_DEF(LVI, 0) + 30) /* 0xEC */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD4LVI (HDA_STREAM_REG_DEF(LVI, 0) + 40) /* 0x10C */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD5LVI (HDA_STREAM_REG_DEF(LVI, 0) + 50) /* 0x12C */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#define ICH6_HDA_REG_SD6LVI (HDA_STREAM_REG_DEF(LVI, 0) + 60) /* 0x14C */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#define ICH6_HDA_REG_SD7LVI (HDA_STREAM_REG_DEF(LVI, 0) + 70) /* 0x16C */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#define SDLVI(pState, num) HDA_REG((pState), SD(LVI, num))
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD0FIFOW 37 /* 0x8E */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD1FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 10) /* 0xAE */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD2FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 20) /* 0xCE */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD3FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 30) /* 0xEE */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#define ICH6_HDA_REG_SD4FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 40) /* 0x10E */
56970d3a1944c7c073d66266cd52449835221badvboxsync#define ICH6_HDA_REG_SD5FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 50) /* 0x12E */
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync#define ICH6_HDA_REG_SD6FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 60) /* 0x14E */
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync#define ICH6_HDA_REG_SD7FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 70) /* 0x16E */
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync#define ICH6_HDA_REG_SD0FIFOS 38 /* 0x90 */
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync#define ICH6_HDA_REG_SD1FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 10) /* 0xB0 */
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define ICH6_HDA_REG_SD2FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 20) /* 0xD0 */
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define ICH6_HDA_REG_SD3FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 30) /* 0xF0 */
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define ICH6_HDA_REG_SD4FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 40) /* 0x110 */
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define ICH6_HDA_REG_SD5FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 50) /* 0x130 */
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync#define ICH6_HDA_REG_SD6FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 60) /* 0x150 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD7FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 70) /* 0x170 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define SDFIFOS(pState, num) HDA_REG((pState), SD(FIFOS, num))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD0FMT 39 /* 0x92 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD1FMT (HDA_STREAM_REG_DEF(FMT, 0) + 10) /* 0xB2 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD2FMT (HDA_STREAM_REG_DEF(FMT, 0) + 20) /* 0xD2 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD3FMT (HDA_STREAM_REG_DEF(FMT, 0) + 30) /* 0xF2 */
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync#define ICH6_HDA_REG_SD4FMT (HDA_STREAM_REG_DEF(FMT, 0) + 40) /* 0x112 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD5FMT (HDA_STREAM_REG_DEF(FMT, 0) + 50) /* 0x132 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD6FMT (HDA_STREAM_REG_DEF(FMT, 0) + 60) /* 0x152 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD7FMT (HDA_STREAM_REG_DEF(FMT, 0) + 70) /* 0x172 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define SDFMT(pState, num) (HDA_REG((pState), SD(FMT, num)))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_SDFMT_BASE_RATE_SHIFT (14)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_SDFMT_MULT_SHIFT (11)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_SDFMT_MULT_MASK (0x7)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_SDFMT_DIV_SHIFT (8)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_SDFMT_DIV_MASK (0x7)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define SDFMT_BASE_RATE(pState, num) ((SDFMT(pState, num) & HDA_REG_FIELD_FLAG_MASK(SDFMT, BASE_RATE)) >> HDA_REG_FIELD_SHIFT(SDFMT, BASE_RATE))
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync#define SDFMT_MULT(pState, num) ((SDFMT((pState), num) & HDA_REG_FIELD_MASK(SDFMT,MULT)) >> HDA_REG_FIELD_SHIFT(SDFMT, MULT))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define SDFMT_DIV(pState, num) ((SDFMT((pState), num) & HDA_REG_FIELD_MASK(SDFMT,DIV)) >> HDA_REG_FIELD_SHIFT(SDFMT, DIV))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD0BDPL 40 /* 0x98 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD1BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 10) /* 0xB8 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD2BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 20) /* 0xD8 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD3BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 30) /* 0xF8 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD4BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 40) /* 0x118 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD5BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 50) /* 0x138 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD6BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 60) /* 0x158 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD7BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 70) /* 0x178 */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define SDBDPL(pState, num) HDA_REG((pState), SD(BDPL, num))
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#define ICH6_HDA_REG_SD0BDPU 41 /* 0x9C */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD1BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 10) /* 0xBC */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define ICH6_HDA_REG_SD2BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 20) /* 0xDC */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_REG_SD3BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 30) /* 0xFC */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_REG_SD4BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 40) /* 0x11C */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define ICH6_HDA_REG_SD5BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 50) /* 0x13C */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#define ICH6_HDA_REG_SD6BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 60) /* 0x15C */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#define ICH6_HDA_REG_SD7BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 70) /* 0x17C */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#define SDBDPU(pState, num) HDA_REG((pState), SD(BDPU, num))
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync/* Predicates */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsynctypedef struct HDABDLEDESC
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync{
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint64_t u64BdleCviAddr;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint32_t u32BdleMaxCvi;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint32_t u32BdleCvi;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint32_t u32BdleCviLen;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint32_t u32BdleCviPos;
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync bool fBdleCviIoc;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync} HDABDLEDESC, *PHDABDLEDESC;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsynctypedef struct INTELHDLinkState
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync{
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /** Pointer to the device instance. */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync PPDMDEVINSR3 pDevIns;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /** Pointer to the connector of the attached audio driver. */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync PPDMIAUDIOCONNECTOR pDrv;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /** Pointer to the attached audio driver. */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync PPDMIBASE pDrvBase;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /** The base interface for LUN\#0. */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync PDMIBASE IBase;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTGCPHYS addrMMReg;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint32_t au32Regs[113];
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync HDABDLEDESC stInBdle;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync HDABDLEDESC stOutBdle;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync HDABDLEDESC stMicBdle;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* Interrupt on completition */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync bool fCviIoc;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint64_t u64CORBBase;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint64_t u64RIRBBase;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint64_t u64DPBase;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* pointer on CORB buf */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint32_t *pu32CorbBuf;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* size in bytes of CORB buf */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint32_t cbCorbBuf;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* pointer on RIRB buf */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint64_t *pu64RirbBuf;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* size in bytes of RIRB buf */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint32_t cbRirbBuf;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* indicates if HDA in reset. */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync bool fInReset;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync CODECState Codec;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint8_t u8Counter;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync uint8_t u8StreamsInReset;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync} INTELHDLinkState;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ICH6_HDASTATE_2_DEVINS(pINTELHD) ((pINTELHD)->pDevIns)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define PCIDEV_2_ICH6_HDASTATE(pPciDev) ((PCIINTELHDLinkState *)(pPciDev))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define ISD0FMT_TO_AUDIO_SELECTOR(pState) (AUDIO_FORMAT_SELECTOR(&(pState)->Codec, In, \
0c94a8282c9042b02f022302a3d987746140eab9vboxsync SDFMT_BASE_RATE(pState, 0), SDFMT_MULT(pState, 0), SDFMT_DIV(pState, 0)))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define OSD0FMT_TO_AUDIO_SELECTOR(pState) (AUDIO_FORMAT_SELECTOR(&(pState)->Codec, Out, \
0c94a8282c9042b02f022302a3d987746140eab9vboxsync SDFMT_BASE_RATE(pState, 4), SDFMT_MULT(pState, 4), SDFMT_DIV(pState, 4)))
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsynctypedef struct PCIINTELHDLinkState
0c94a8282c9042b02f022302a3d987746140eab9vboxsync{
0c94a8282c9042b02f022302a3d987746140eab9vboxsync PCIDevice dev;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync INTELHDLinkState hda;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync} PCIINTELHDLinkState;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegReadUnimplemented(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegWriteUnimplemented(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegReadGCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegWriteGCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegReadSTATESTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegWriteSTATESTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegReadGCAP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncDECLCALLBACK(int)hdaRegReadINTSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncDECLCALLBACK(int)hdaRegWriteINTSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegWriteCORBWP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegWriteCORBRP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegWriteCORBCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegWriteCORBSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegWriteRIRBWP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncDECLCALLBACK(int)hdaRegWriteRIRBSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncDECLCALLBACK(int)hdaRegWriteIRS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncDECLCALLBACK(int)hdaRegWriteSDCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncDECLCALLBACK(int)hdaRegReadSDCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncDECLCALLBACK(int)hdaRegWriteSDSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncDECLCALLBACK(int)hdaRegWriteSDLVI(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncDECLCALLBACK(int)hdaRegWriteSDBDPL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncDECLCALLBACK(int)hdaRegWriteSDBDPU(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncDECLCALLBACK(int)hdaRegWriteBase(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncDECLCALLBACK(int)hdaRegReadU32(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncDECLCALLBACK(int)hdaRegWriteU32(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsyncDECLCALLBACK(int)hdaRegReadU24(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsyncDECLCALLBACK(int)hdaRegWriteU24(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsyncDECLCALLBACK(int)hdaRegReadU16(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsyncDECLCALLBACK(int)hdaRegWriteU16(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsyncDECLCALLBACK(int)hdaRegReadU8(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsyncDECLCALLBACK(int)hdaRegWriteU8(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsyncstatic int hdaLookup(INTELHDLinkState* pState, uint32_t u32Offset);
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsyncstatic void fetch_bd(INTELHDLinkState *pState, PHDABDLEDESC pBdle, uint64_t u64BaseDMA);
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync/* see 302349 p 6.2*/
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsyncconst static struct stIchIntelHDRegMap
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync{
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync /** Register offset in the register space. */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync uint32_t offset;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync /** Size in bytes. Registers of size > 4 are in fact tables. */
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync uint32_t size;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync /** Readable bits. */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync uint32_t readable;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync /** Writable bits. */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync uint32_t writable;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync /** Read callback. */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync int (*pfnRead)(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync /** Write callback. */
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync int (*pfnWrite)(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync /** Abbreviated name. */
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync const char *abbrev;
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync /** Full name. */
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync const char *name;
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync} s_ichIntelHDRegMap[] =
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync{
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync /* offset size read mask write mask read callback write callback abbrev full name */
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync /*------- ------- ---------- ---------- ----------------------- ------------------------ ---------- ------------------------------*/
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x00000, 0x00002, 0x0000FFFB, 0x00000000, hdaRegReadGCAP , hdaRegWriteUnimplemented, "GCAP" , "Global Capabilities" },
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x00002, 0x00001, 0x000000FF, 0x00000000, hdaRegReadU8 , hdaRegWriteUnimplemented, "VMIN" , "Minor Version" },
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x00003, 0x00001, 0x000000FF, 0x00000000, hdaRegReadU8 , hdaRegWriteUnimplemented, "VMAJ" , "Major Version" },
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x00004, 0x00002, 0x0000FFFF, 0x00000000, hdaRegReadU16 , hdaRegWriteUnimplemented, "OUTPAY" , "Output Payload Capabilities" },
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x00006, 0x00002, 0x0000FFFF, 0x00000000, hdaRegReadU16 , hdaRegWriteUnimplemented, "INPAY" , "Input Payload Capabilities" },
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x00008, 0x00004, 0x00000103, 0x00000103, hdaRegReadGCTL , hdaRegWriteGCTL , "GCTL" , "Global Control" },
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x0000c, 0x00002, 0x00007FFF, 0x00007FFF, hdaRegReadU16 , hdaRegWriteU16 , "WAKEEN" , "Wake Enable" },
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x0000e, 0x00002, 0x00000007, 0x00000007, hdaRegReadU8 , hdaRegWriteSTATESTS , "STATESTS" , "State Change Status" },
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x00010, 0x00002, 0xFFFFFFFF, 0x00000000, hdaRegReadUnimplemented, hdaRegWriteUnimplemented, "GSTS" , "Global Status" },
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x00020, 0x00004, 0xC00000FF, 0xC00000FF, hdaRegReadU32 , hdaRegWriteU32 , "INTCTL" , "Interrupt Control" },
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x00024, 0x00004, 0xC00000FF, 0x00000000, hdaRegReadINTSTS , hdaRegWriteUnimplemented, "INTSTS" , "Interrupt Status" },
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync //** @todo r=michaln: Are guests really not reading the WALCLK register at all?
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x00030, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadUnimplemented, hdaRegWriteUnimplemented, "WALCLK" , "Wall Clock Counter" },
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync //** @todo r=michaln: Doesn't the SSYNC register need to actually stop the stream(s)?
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x00034, 0x00004, 0x000000FF, 0x000000FF, hdaRegReadU32 , hdaRegWriteU32 , "SSYNC" , "Stream Synchronization" },
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x00040, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteBase , "CORBLBASE" , "CORB Lower Base Address" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x00044, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteBase , "CORBUBASE" , "CORB Upper Base Address" },
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync { 0x00048, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteCORBWP , "CORBWP" , "CORB Write Pointer" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x0004A, 0x00002, 0x000000FF, 0x000080FF, hdaRegReadU8 , hdaRegWriteCORBRP , "CORBRP" , "CORB Read Pointer" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x0004C, 0x00001, 0x00000003, 0x00000003, hdaRegReadU8 , hdaRegWriteCORBCTL , "CORBCTL" , "CORB Control" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x0004D, 0x00001, 0x00000001, 0x00000001, hdaRegReadU8 , hdaRegWriteCORBSTS , "CORBSTS" , "CORB Status" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x0004E, 0x00001, 0x000000F3, 0x00000000, hdaRegReadU8 , hdaRegWriteUnimplemented, "CORBSIZE" , "CORB Size" },
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync { 0x00050, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteBase , "RIRBLBASE" , "RIRB Lower Base Address" },
1379dfd407ada5fab15655776896f13b61a951fdvboxsync { 0x00054, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteBase , "RIRBUBASE" , "RIRB Upper Base Address" },
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync { 0x00058, 0x00002, 0x000000FF, 0x00008000, hdaRegReadU8, hdaRegWriteRIRBWP , "RIRBWP" , "RIRB Write Pointer" },
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync { 0x0005A, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteU16 , "RINTCNT" , "Response Interrupt Count" },
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync { 0x0005C, 0x00001, 0x00000007, 0x00000007, hdaRegReadU8 , hdaRegWriteU8 , "RIRBCTL" , "RIRB Control" },
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync { 0x0005D, 0x00001, 0x00000005, 0x00000005, hdaRegReadU8 , hdaRegWriteRIRBSTS , "RIRBSTS" , "RIRB Status" },
1379dfd407ada5fab15655776896f13b61a951fdvboxsync { 0x0005E, 0x00001, 0x000000F3, 0x00000000, hdaRegReadU8 , hdaRegWriteUnimplemented, "RIRBSIZE" , "RIRB Size" },
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync { 0x00060, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "IC" , "Immediate Command" },
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync { 0x00064, 0x00004, 0x00000000, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteUnimplemented, "IR" , "Immediate Response" },
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync { 0x00068, 0x00004, 0x00000002, 0x00000002, hdaRegReadU16 , hdaRegWriteIRS , "IRS" , "Immediate Command Status" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x00070, 0x00004, 0xFFFFFFFF, 0xFFFFFF81, hdaRegReadU32 , hdaRegWriteBase , "DPLBASE" , "DMA Position Lower Base" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x00074, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteBase , "DPUBASE" , "DMA Position Upper Base" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x00080, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , "ISD0CTL" , "Input Stream Descriptor 0 (ICD0) Control" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x00083, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , "ISD0STS" , "ISD0 Status" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x00084, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , "ISD0LPIB" , "ISD0 Link Position In Buffer" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x00088, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "ISD0CBL" , "ISD0 Cyclic Buffer Length" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x0008C, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , "ISD0LVI" , "ISD0 Last Valid Index" },
1379dfd407ada5fab15655776896f13b61a951fdvboxsync { 0x0008E, 0x00002, 0x00000005, 0x00000005, hdaRegReadU16 , hdaRegWriteU16 , "ISD0FIFOW", "ISD0 FIFO Watermark" },
1379dfd407ada5fab15655776896f13b61a951fdvboxsync { 0x00090, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteU16 , "ISD0FIFOS", "ISD0 FIFO Size" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x00092, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteU16 , "ISD0FMT" , "ISD0 Format" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x00098, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , "ISD0BDPL" , "ISD0 Buffer Descriptor List Pointer-Lower Base Address" },
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync { 0x0009C, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , "ISD0BDPU" , "ISD0 Buffer Descriptor List Pointer-Upper Base Address" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync { 0x000A0, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , "ISD1CTL" , "Input Stream Descriptor 1 (ISD1) Control" },
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync { 0x000A3, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , "ISD1STS" , "ISD1 Status" },
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync { 0x000A4, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , "ISD1LPIB" , "ISD1 Link Position In Buffer" },
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync { 0x000A8, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "ISD1CBL" , "ISD1 Cyclic Buffer Length" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x000AC, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , "ISD1LVI" , "ISD1 Last Valid Index" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x000AE, 0x00002, 0x00000005, 0x00000005, hdaRegReadU16 , hdaRegWriteU16 , "ISD1FIFOW", "ISD1 FIFO Watermark" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x000B0, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteU16 , "ISD1FIFOS", "ISD1 FIFO Size" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x000B2, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteU16 , "ISD1FMT" , "ISD1 Format" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x000B8, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , "ISD1BDPL" , "ISD1 Buffer Descriptor List Pointer-Lower Base Address" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x000BC, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , "ISD1BDPU" , "ISD1 Buffer Descriptor List Pointer-Upper Base Address" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x000C0, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , "ISD2CTL" , "Input Stream Descriptor 2 (ISD2) Control" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x000C3, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , "ISD2STS" , "ISD2 Status" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x000C4, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , "ISD2LPIB" , "ISD2 Link Position In Buffer" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x000C8, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "ISD2CBL" , "ISD2 Cyclic Buffer Length" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x000CC, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , "ISD2LVI" , "ISD2 Last Valid Index" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x000CE, 0x00002, 0x00000005, 0x00000005, hdaRegReadU16 , hdaRegWriteU16 , "ISD2FIFOW", "ISD2 FIFO Watermark" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x000D0, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteU16 , "ISD2FIFOS", "ISD2 FIFO Size" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x000D2, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteU16 , "ISD2FMT" , "ISD2 Format" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x000D8, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , "ISD2BDPL" , "ISD2 Buffer Descriptor List Pointer-Lower Base Address" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x000DC, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , "ISD2BDPU" , "ISD2 Buffer Descriptor List Pointer-Upper Base Address" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x000E0, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , "ISD3CTL" , "Input Stream Descriptor 3 (ISD3) Control" },
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x000E3, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , "ISD3STS" , "ISD3 Status" },
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x000E4, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , "ISD3LPIB" , "ISD3 Link Position In Buffer" },
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync { 0x000E8, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "ISD3CBL" , "ISD3 Cyclic Buffer Length" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x000EC, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , "ISD3LVI" , "ISD3 Last Valid Index" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x000EE, 0x00002, 0x00000005, 0x00000005, hdaRegReadU16 , hdaRegWriteU16 , "ISD3FIFOW", "ISD3 FIFO Watermark" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x000F0, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteU16 , "ISD3FIFOS", "ISD3 FIFO Size" },
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x000F2, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteU16 , "ISD3FMT" , "ISD3 Format" },
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync { 0x000F8, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , "ISD3BDPL" , "ISD3 Buffer Descriptor List Pointer-Lower Base Address" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x000FC, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , "ISD3BDPU" , "ISD3 Buffer Descriptor List Pointer-Upper Base Address" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x00100, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadSDCTL , hdaRegWriteSDCTL , "OSD0CTL" , "Input Stream Descriptor 0 (OSD0) Control" },
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync { 0x00103, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , "OSD0STS" , "OSD0 Status" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x00104, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , "OSD0LPIB" , "OSD0 Link Position In Buffer" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x00108, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "OSD0CBL" , "OSD0 Cyclic Buffer Length" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x0010C, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , "OSD0LVI" , "OSD0 Last Valid Index" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x0010E, 0x00002, 0x00000005, 0x00000005, hdaRegReadU16 , hdaRegWriteU16 , "OSD0FIFOW", "OSD0 FIFO Watermark" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x00110, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteU16 , "OSD0FIFOS", "OSD0 FIFO Size" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x00112, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteU16 , "OSD0FMT" , "OSD0 Format" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x00118, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , "OSD0BDPL" , "OSD0 Buffer Descriptor List Pointer-Lower Base Address" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x0011C, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , "OSD0BDPU" , "OSD0 Buffer Descriptor List Pointer-Upper Base Address" },
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync { 0x00120, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , "OSD1CTL" , "Input Stream Descriptor 0 (OSD1) Control" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x00123, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , "OSD1STS" , "OSD1 Status" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x00124, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , "OSD1LPIB" , "OSD1 Link Position In Buffer" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x00128, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "OSD1CBL" , "OSD1 Cyclic Buffer Length" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x0012C, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , "OSD1LVI" , "OSD1 Last Valid Index" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x0012E, 0x00002, 0x00000005, 0x00000005, hdaRegReadU16 , hdaRegWriteU16 , "OSD1FIFOW", "OSD1 FIFO Watermark" },
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync { 0x00130, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteU16 , "OSD1FIFOS", "OSD1 FIFO Size" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x00132, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteU16 , "OSD1FMT" , "OSD1 Format" },
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync { 0x00138, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , "OSD1BDPL" , "OSD1 Buffer Descriptor List Pointer-Lower Base Address" },
a66ec044d2a64d926996cd24da5faadccb070be3vboxsync { 0x0013C, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , "OSD1BDPU" , "OSD1 Buffer Descriptor List Pointer-Upper Base Address" },
a66ec044d2a64d926996cd24da5faadccb070be3vboxsync
a66ec044d2a64d926996cd24da5faadccb070be3vboxsync { 0x00140, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , "OSD2CTL" , "Input Stream Descriptor 0 (OSD2) Control" },
a66ec044d2a64d926996cd24da5faadccb070be3vboxsync { 0x00143, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , "OSD2STS" , "OSD2 Status" },
a66ec044d2a64d926996cd24da5faadccb070be3vboxsync { 0x00144, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , "OSD2LPIB" , "OSD2 Link Position In Buffer" },
a66ec044d2a64d926996cd24da5faadccb070be3vboxsync { 0x00148, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "OSD2CBL" , "OSD2 Cyclic Buffer Length" },
a66ec044d2a64d926996cd24da5faadccb070be3vboxsync { 0x0014C, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , "OSD2LVI" , "OSD2 Last Valid Index" },
a66ec044d2a64d926996cd24da5faadccb070be3vboxsync { 0x0014E, 0x00002, 0x00000005, 0x00000005, hdaRegReadU16 , hdaRegWriteU16 , "OSD2FIFOW", "OSD2 FIFO Watermark" },
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync { 0x00150, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteU16 , "OSD2FIFOS", "OSD2 FIFO Size" },
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync { 0x00152, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteU16 , "OSD2FMT" , "OSD2 Format" },
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync { 0x00158, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , "OSD2BDPL" , "OSD2 Buffer Descriptor List Pointer-Lower Base Address" },
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync { 0x0015C, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , "OSD2BDPU" , "OSD2 Buffer Descriptor List Pointer-Upper Base Address" },
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync { 0x00160, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , "OSD3CTL" , "Input Stream Descriptor 0 (OSD3) Control" },
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync { 0x00163, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , "OSD3STS" , "OSD3 Status" },
0c94a8282c9042b02f022302a3d987746140eab9vboxsync { 0x00164, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , "OSD3LPIB" , "OSD3 Link Position In Buffer" },
0c94a8282c9042b02f022302a3d987746140eab9vboxsync { 0x00168, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "OSD3CBL" , "OSD3 Cyclic Buffer Length" },
0c94a8282c9042b02f022302a3d987746140eab9vboxsync { 0x0016C, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , "OSD3LVI" , "OSD3 Last Valid Index" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x0016E, 0x00002, 0x00000005, 0x00000005, hdaRegReadU16 , hdaRegWriteU16 , "OSD3FIFOW", "OSD3 FIFO Watermark" },
0c94a8282c9042b02f022302a3d987746140eab9vboxsync { 0x00170, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteU16 , "OSD3FIFOS", "OSD3 FIFO Size" },
0c94a8282c9042b02f022302a3d987746140eab9vboxsync { 0x00172, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteU16 , "OSD3FMT" , "OSD3 Format" },
0c94a8282c9042b02f022302a3d987746140eab9vboxsync { 0x00178, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , "OSD3BDPL" , "OSD3 Buffer Descriptor List Pointer-Lower Base Address" },
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync { 0x0017C, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , "OSD3BDPU" , "OSD3 Buffer Descriptor List Pointer-Upper Base Address" },
0c94a8282c9042b02f022302a3d987746140eab9vboxsync};
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsyncstatic int hdaProcessInterrupt(INTELHDLinkState* pState)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync{
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync#define IS_INTERRUPT_OCCURED_AND_ENABLED(pState, num) \
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync ( INTCTL_SX((pState), num) \
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync && (SDSTS(pState, num) & HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS)))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync bool fIrq = false;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if( INTCTL_CIE(pState)
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync && ( RIRBSTS_RINTFL(pState)
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync || RIRBSTS_RIRBOIS(pState)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync || STATESTS(pState)))
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync fIrq = true;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if ( IS_INTERRUPT_OCCURED_AND_ENABLED(pState, 0)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync || IS_INTERRUPT_OCCURED_AND_ENABLED(pState, 4))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync fIrq = true;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (INTCTL_GIE(pState))
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync Log(("hda: irq %s\n", fIrq ? "asserted" : "deasserted"));
20f21077abf35d7b7b618acb159267933907407fvboxsync PDMDevHlpPCISetIrq(ICH6_HDASTATE_2_DEVINS(pState), 0 , fIrq);
20f21077abf35d7b7b618acb159267933907407fvboxsync }
20f21077abf35d7b7b618acb159267933907407fvboxsync return VINF_SUCCESS;
0d8c2135d15345cc68111eea91052cdf5518d7e3vboxsync}
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsyncstatic int hdaLookup(INTELHDLinkState* pState, uint32_t u32Offset)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync{
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync int index = 0;
20f21077abf35d7b7b618acb159267933907407fvboxsync //** @todo r=michaln: A linear search of an array with over 100 elements is very inefficient.
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync for (;index < (int)(sizeof(s_ichIntelHDRegMap)/sizeof(s_ichIntelHDRegMap[0])); ++index)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync {
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if ( u32Offset >= s_ichIntelHDRegMap[index].offset
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync && u32Offset < s_ichIntelHDRegMap[index].offset + s_ichIntelHDRegMap[index].size)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return index;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /* Aliases HDA spec 3.3.45 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync switch(u32Offset)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync case 0x2084:
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return HDA_REG_IND_NAME(SD0LPIB);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync case 0x20A4:
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return HDA_REG_IND_NAME(SD1LPIB);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync case 0x20C4:
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return HDA_REG_IND_NAME(SD2LPIB);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync case 0x20E4:
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return HDA_REG_IND_NAME(SD3LPIB);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync case 0x2104:
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return HDA_REG_IND_NAME(SD4LPIB);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync case 0x2124:
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return HDA_REG_IND_NAME(SD5LPIB);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync case 0x2144:
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync return HDA_REG_IND_NAME(SD6LPIB);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync case 0x2164:
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return HDA_REG_IND_NAME(SD7LPIB);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return -1;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync}
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsyncstatic int hdaCmdSync(INTELHDLinkState *pState, bool fLocal)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync{
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync int rc = VINF_SUCCESS;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (fLocal)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync Assert((HDA_REG_FLAG_VALUE(pState, CORBCTL, DMA)));
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync rc = PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(pState), pState->u64CORBBase, pState->pu32CorbBuf, pState->cbCorbBuf);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (RT_FAILURE(rc))
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync AssertRCReturn(rc, rc);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync#ifdef DEBUG_CMD_BUFFER
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync uint8_t i = 0;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync do
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync Log(("hda: corb%02x: ", i));
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync uint8_t j = 0;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync do
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync const char *prefix;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync if ((i + j) == CORBRP(pState))
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync prefix = "[R]";
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync else if ((i + j) == CORBWP(pState))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync prefix = "[W]";
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync else
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync prefix = " "; /* three spaces */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync Log(("%s%08x", prefix, pState->pu32CorbBuf[i + j]));
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync j++;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync } while (j < 8);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync Log(("\n"));
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync i += 8;
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync } while(i != 0);
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync#endif
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync }
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync else
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync Assert((HDA_REG_FLAG_VALUE(pState, RIRBCTL, DMA)));
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync rc = PDMDevHlpPhysWrite(ICH6_HDASTATE_2_DEVINS(pState), pState->u64RIRBBase, pState->pu64RirbBuf, pState->cbRirbBuf);
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync if (RT_FAILURE(rc))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync AssertRCReturn(rc, rc);
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync#ifdef DEBUG_CMD_BUFFER
20f21077abf35d7b7b618acb159267933907407fvboxsync uint8_t i = 0;
20f21077abf35d7b7b618acb159267933907407fvboxsync do {
20f21077abf35d7b7b618acb159267933907407fvboxsync Log(("hda: rirb%02x: ", i));
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync uint8_t j = 0;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync do {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync const char *prefix;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if ((i + j) == RIRBWP(pState))
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync prefix = "[W]";
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync else
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync prefix = " ";
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync Log((" %s%016lx", prefix, pState->pu64RirbBuf[i + j]));
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync } while (++j < 8);
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync Log(("\n"));
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync i += 8;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync } while (i != 0);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#endif
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return rc;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync}
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsyncstatic int hdaCORBCmdProcess(INTELHDLinkState *pState)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync{
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync int rc;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync uint8_t corbRp;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync uint8_t corbWp;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync uint8_t rirbWp;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync PFNCODECVERBPROCESSOR pfn = (PFNCODECVERBPROCESSOR)NULL;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync rc = hdaCmdSync(pState, true);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (RT_FAILURE(rc))
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync AssertRCReturn(rc, rc);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync corbRp = CORBRP(pState);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync corbWp = CORBWP(pState);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync rirbWp = RIRBWP(pState);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync Assert((corbWp != corbRp));
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync Log(("hda: CORB(RP:%x, WP:%x) RIRBWP:%x\n", CORBRP(pState), CORBWP(pState), RIRBWP(pState)));
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync while (corbRp != corbWp)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync {
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync uint32_t cmd;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync uint64_t resp;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync corbRp++;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync cmd = pState->pu32CorbBuf[corbRp];
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync rc = (pState)->Codec.pfnLookup(&pState->Codec, cmd, &pfn);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (RT_FAILURE(rc))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync AssertRCReturn(rc, rc);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync Assert(pfn);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync (rirbWp)++;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync rc = pfn(&pState->Codec, cmd, &resp);
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync if (RT_FAILURE(rc))
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync AssertRCReturn(rc, rc);
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync Log(("hda: verb:%08x->%016lx\n", cmd, resp));
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync if ( (resp & CODEC_RESPONSE_UNSOLICITED)
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync && !HDA_REG_FLAG_VALUE(pState, GCTL, UR))
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync {
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync Log(("hda: unexpected unsolicited response.\n"));
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync pState->au32Regs[ICH6_HDA_REG_CORBRP] = corbRp;
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync return rc;
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync }
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync pState->pu64RirbBuf[rirbWp] = resp;
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync pState->u8Counter++;
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync if (pState->u8Counter == RINTCNT_N(pState))
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync break;
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync }
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync pState->au32Regs[ICH6_HDA_REG_CORBRP] = corbRp;
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync pState->au32Regs[ICH6_HDA_REG_RIRBWP] = rirbWp;
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync rc = hdaCmdSync(pState, false);
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync Log(("hda: CORB(RP:%x, WP:%x) RIRBWP:%x\n", CORBRP(pState), CORBWP(pState), RIRBWP(pState)));
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync if (RIRBCTL_RIRB_RIC(pState))
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync {
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync RIRBSTS((pState)) |= HDA_REG_FIELD_FLAG_MASK(RIRBSTS,RINTFL);
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync pState->u8Counter = 0;
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync rc = hdaProcessInterrupt(pState);
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync }
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync if (RT_FAILURE(rc))
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync AssertRCReturn(rc, rc);
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync return rc;
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync}
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsyncstatic void hdaStreamReset(INTELHDLinkState *pState, uint32_t u32Offset)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync{
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync Log(("hda: reset of stream (%x) started\n", u32Offset));
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync Log(("hda: reset of stream (%x) finished\n", u32Offset));
9b1d52365befbce1af8f32d53c2e563ee9169501vboxsync}
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegReadUnimplemented(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync{
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync *pu32Value = 0;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync return VINF_SUCCESS;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync}
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsyncDECLCALLBACK(int)hdaRegWriteUnimplemented(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsync{
9b1d52365befbce1af8f32d53c2e563ee9169501vboxsync return VINF_SUCCESS;
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsync}
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsync/* U8 */
9b1d52365befbce1af8f32d53c2e563ee9169501vboxsyncDECLCALLBACK(int)hdaRegReadU8(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsync{
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsync Assert(((pState->au32Regs[index] & s_ichIntelHDRegMap[index].readable) & 0xffffff00) == 0);
9b1d52365befbce1af8f32d53c2e563ee9169501vboxsync return hdaRegReadU32(pState, offset, index, pu32Value);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync}
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegWriteU8(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync{
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync Assert(((u32Value & 0xffffff00) == 0));
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync return hdaRegWriteU32(pState, offset, index, u32Value);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync}
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync/* U16 */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegReadU16(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync{
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync Assert(((pState->au32Regs[index] & s_ichIntelHDRegMap[index].readable) & 0xffff0000) == 0);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync return hdaRegReadU32(pState, offset, index, pu32Value);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync}
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegWriteU16(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync{
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync Assert(((u32Value & 0xffff0000) == 0));
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync return hdaRegWriteU32(pState, offset, index, u32Value);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync}
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync/* U24 */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegReadU24(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync{
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync Assert(((pState->au32Regs[index] & s_ichIntelHDRegMap[index].readable) & 0xff000000) == 0);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync return hdaRegReadU32(pState, offset, index, pu32Value);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync}
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncDECLCALLBACK(int)hdaRegWriteU24(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync{
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync Assert(((u32Value & 0xff000000) == 0));
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync return hdaRegWriteU32(pState, offset, index, u32Value);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync}
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync/* U32 */
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsyncDECLCALLBACK(int)hdaRegReadU32(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync{
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync *pu32Value = pState->au32Regs[index] & s_ichIntelHDRegMap[index].readable;
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsync return VINF_SUCCESS;
2346cab03e0c9fba1765c8e21ef98f03c8564cd8vboxsync}
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsyncDECLCALLBACK(int)hdaRegWriteU32(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync{
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync pState->au32Regs[index] = (u32Value & s_ichIntelHDRegMap[index].writable)
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync | (pState->au32Regs[index] & ~s_ichIntelHDRegMap[index].writable);
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync return VINF_SUCCESS;
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync}
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsync
81614fc60e096e714022d10d38b70a36b9b21d48vboxsyncDECLCALLBACK(int)hdaRegReadGCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync{
a655881be920ead6948994168c5ee09e5798aa05vboxsync return hdaRegReadU32(pState, offset, index, pu32Value);
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync}
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsyncDECLCALLBACK(int)hdaRegWriteGCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync{
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (u32Value & HDA_REG_FIELD_FLAG_MASK(GCTL, RST))
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync {
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync /* exit reset state */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync GCTL(pState) |= HDA_REG_FIELD_FLAG_MASK(GCTL, RST);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync pState->fInReset = false;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* enter reset state*/
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if ( HDA_REG_FLAG_VALUE(pState, CORBCTL, DMA)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync || HDA_REG_FLAG_VALUE(pState, RIRBCTL, DMA))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Log(("hda: HDA enters in reset with DMA(RIRB:%s, CORB:%s)\n",
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync HDA_REG_FLAG_VALUE(pState, CORBCTL, DMA) ? "on" : "off",
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync HDA_REG_FLAG_VALUE(pState, RIRBCTL, DMA) ? "on" : "off"));
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hdaReset(ICH6_HDASTATE_2_DEVINS(pState));
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync GCTL(pState) &= ~HDA_REG_FIELD_FLAG_MASK(GCTL, RST);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync pState->fInReset = true;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (u32Value & HDA_REG_FIELD_FLAG_MASK(GCTL, FSH))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* Flush: GSTS:1 set, see 6.2.6*/
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync GSTS(pState) |= HDA_REG_FIELD_FLAG_MASK(GSTS, FSH); /* set the flush state */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* DPLBASE and DPUBASE, should be initialized with initial value (see 6.2.6)*/
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return VINF_SUCCESS;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync}
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncDECLCALLBACK(int)hdaRegWriteSTATESTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync{
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync uint32_t v = pState->au32Regs[index];
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync uint32_t nv = u32Value & ICH6_HDA_STATES_SCSF;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync pState->au32Regs[index] = (v ^ nv) & v; /* write of 1 clears corresponding bit */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync return VINF_SUCCESS;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync}
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncDECLCALLBACK(int)hdaRegReadINTSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync{
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync uint32_t v = 0;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if ( RIRBSTS_RIRBOIS(pState)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync || RIRBSTS_RINTFL(pState)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync || HDA_REG_FLAG_VALUE(pState, CORBSTS, CMEI)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync || STATESTS(pState))
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync v |= RT_BIT(30);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync#define HDA_IS_STREAM_EVENT(pState, stream) \
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync ( (SDSTS((pState),stream) & HDA_REG_FIELD_FLAG_MASK(SDSTS, DE)) \
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync || (SDSTS((pState),stream) & HDA_REG_FIELD_FLAG_MASK(SDSTS, FE)) \
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync || (SDSTS((pState),stream) & HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS)))
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync#define MARK_STREAM(pState, stream, v) do {(v) |= HDA_IS_STREAM_EVENT((pState),stream) ? RT_BIT((stream)) : 0;}while(0)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync MARK_STREAM(pState, 0, v);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync MARK_STREAM(pState, 1, v);
56970d3a1944c7c073d66266cd52449835221badvboxsync MARK_STREAM(pState, 2, v);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync MARK_STREAM(pState, 3, v);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync MARK_STREAM(pState, 4, v);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync MARK_STREAM(pState, 5, v);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync MARK_STREAM(pState, 6, v);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync MARK_STREAM(pState, 7, v);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync v |= v ? RT_BIT(31) : 0;
56970d3a1944c7c073d66266cd52449835221badvboxsync *pu32Value = v;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return VINF_SUCCESS;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync}
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncDECLCALLBACK(int)hdaRegReadGCAP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync{
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync return hdaRegReadU16(pState, offset, index, pu32Value);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync}
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncDECLCALLBACK(int)hdaRegWriteCORBRP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync{
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (u32Value & HDA_REG_FIELD_FLAG_MASK(CORBRP, RST))
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync CORBRP(pState) = 0;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync else
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync return hdaRegWriteU8(pState, offset, index, u32Value);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync return VINF_SUCCESS;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync}
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncDECLCALLBACK(int)hdaRegWriteCORBCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync{
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync int rc = hdaRegWriteU8(pState, offset, index, u32Value);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync AssertRC(rc);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if ( CORBWP(pState) != CORBRP(pState)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync && HDA_REG_FLAG_VALUE(pState, CORBCTL, DMA) != 0)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync return hdaCORBCmdProcess(pState);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync return rc;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync}
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncDECLCALLBACK(int)hdaRegWriteCORBSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync{
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync uint32_t v = CORBSTS(pState);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync v = (v ^ u32Value) & v;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync CORBSTS(pState) = v;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync return VINF_SUCCESS;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync}
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncDECLCALLBACK(int)hdaRegWriteCORBWP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync{
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync int rc;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync rc = hdaRegWriteU16(pState, offset, index, u32Value);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (RT_FAILURE(rc))
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync AssertRCReturn(rc, rc);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (CORBWP(pState) == CORBRP(pState))
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync return VINF_SUCCESS;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (!HDA_REG_FLAG_VALUE(pState, CORBCTL, DMA))
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync return VINF_SUCCESS;
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync rc = hdaCORBCmdProcess(pState);
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync return rc;
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync}
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncDECLCALLBACK(int)hdaRegReadSDCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync{
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync return hdaRegReadU24(pState, offset, index, pu32Value);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync}
56970d3a1944c7c073d66266cd52449835221badvboxsync#define HDA_STREAM_BITMASK(offset) (1 << (((offset) - 0x80) >> 5))
56970d3a1944c7c073d66266cd52449835221badvboxsync#define HDA_IS_STREAM_IN_RESET(pState, offset) ((pState)->u8StreamsInReset & HDA_STREAM_BITMASK((offset)))
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncDECLCALLBACK(int)hdaRegWriteSDCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync{
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if(u32Value & HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST))
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync LogRel(("hda: guest has iniated hw stream reset\n"));
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync pState->u8StreamsInReset |= HDA_STREAM_BITMASK(offset);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync hdaStreamReset(pState, offset);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync HDA_REG_IND(pState, index) &= ~HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync else if (HDA_IS_STREAM_IN_RESET(pState, offset))
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync LogRel(("hda: guest has iniated exit of stream reset\n"));
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync pState->u8StreamsInReset &= ~HDA_STREAM_BITMASK(offset);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync HDA_REG_IND(pState, index) &= ~HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST);
2d66abeefb9716ed570bb5714884d3fe08629452vboxsync }
2d66abeefb9716ed570bb5714884d3fe08629452vboxsync /* @todo: use right offsets for right streams */
2d66abeefb9716ed570bb5714884d3fe08629452vboxsync if (u32Value & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN))
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync {
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync Log(("hda: DMA(%x) switched on\n", offset));
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync if (offset == 0x80)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync AUD_set_active_in(ISD0FMT_TO_AUDIO_SELECTOR(pState), 1);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (offset == 0x100)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync uint64_t u64BaseDMA = SDBDPL(pState, 4);
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync u64BaseDMA |= (((uint64_t)SDBDPU(pState, 4)) << 32);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (u64BaseDMA)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync AUD_set_active_out(OSD0FMT_TO_AUDIO_SELECTOR(pState), 1);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync }
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync }
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync else
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync Log(("hda: DMA(%x) switched off\n", offset));
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (offset == 0x80)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync AUD_set_active_in(ISD0FMT_TO_AUDIO_SELECTOR(pState), 0);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (offset == 0x100)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync SDSTS(pState, 4) &= ~(1<<5);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync AUD_set_active_out(OSD0FMT_TO_AUDIO_SELECTOR(pState), 0);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync int rc = hdaRegWriteU24(pState, offset, index, u32Value);
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync if (RT_FAILURE(rc))
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync AssertRCReturn(rc, VINF_SUCCESS);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync return rc;
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync}
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsyncDECLCALLBACK(int)hdaRegWriteSDSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync{
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync uint32_t v = HDA_REG_IND(pState, index);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync v ^= (u32Value & v);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync HDA_REG_IND(pState, index) = v;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync hdaProcessInterrupt(pState);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync#if 0
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if ( v != u32Value
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync && (INTCTL_SALL(pState) & (1 << ((offset - 0x83) >> 5))))
e70bda5438c3582164d26f171a8bc8d3d7da1e12vboxsync {
e70bda5438c3582164d26f171a8bc8d3d7da1e12vboxsync int rc;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync rc = hdaProcessInterrupt(pState);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (RT_FAILURE(rc))
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync AssertRCReturn(rc, rc);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync }
20f21077abf35d7b7b618acb159267933907407fvboxsync#endif
20f21077abf35d7b7b618acb159267933907407fvboxsync return VINF_SUCCESS;
20f21077abf35d7b7b618acb159267933907407fvboxsync}
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsyncDECLCALLBACK(int)hdaRegWriteSDLVI(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
20f21077abf35d7b7b618acb159267933907407fvboxsync{
20f21077abf35d7b7b618acb159267933907407fvboxsync int rc = hdaRegWriteU32(pState, offset, index, u32Value);
20f21077abf35d7b7b618acb159267933907407fvboxsync if (RT_FAILURE(rc))
20f21077abf35d7b7b618acb159267933907407fvboxsync AssertRCReturn(rc, VINF_SUCCESS);
20f21077abf35d7b7b618acb159267933907407fvboxsync return rc;
20f21077abf35d7b7b618acb159267933907407fvboxsync}
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsyncDECLCALLBACK(int)hdaRegWriteSDBDPL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync{
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync int rc = hdaRegWriteU32(pState, offset, index, u32Value);
e70bda5438c3582164d26f171a8bc8d3d7da1e12vboxsync if (RT_FAILURE(rc))
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync AssertRCReturn(rc, VINF_SUCCESS);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync return rc;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync}
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncDECLCALLBACK(int)hdaRegWriteSDBDPU(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync{
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync int rc = hdaRegWriteU32(pState, offset, index, u32Value);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync if (RT_FAILURE(rc))
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync AssertRCReturn(rc, VINF_SUCCESS);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync return rc;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync}
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsyncDECLCALLBACK(int)hdaRegWriteIRS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync{
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync int rc = VINF_SUCCESS;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync uint64_t resp;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync PFNCODECVERBPROCESSOR pfn = (PFNCODECVERBPROCESSOR)NULL;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync if ( u32Value & HDA_REG_FIELD_FLAG_MASK(IRS, ICB)
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync && !IRS_ICB(pState))
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync {
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync uint32_t cmd = IC(pState);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync IRS(pState) = HDA_REG_FIELD_FLAG_MASK(IRS, ICB); /* busy */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync Log(("hda: IC:%x\n", cmd));
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync rc = pState->Codec.pfnLookup(&pState->Codec, cmd, &pfn);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync if (RT_FAILURE(rc))
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync AssertRCReturn(rc, rc);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync rc = pfn(&pState->Codec, cmd, &resp);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync if (RT_FAILURE(rc))
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync AssertRCReturn(rc, rc);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync IR(pState) = (uint32_t)resp;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync Log(("hda: IR:%x\n", IR(pState)));
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync IRS(pState) = HDA_REG_FIELD_FLAG_MASK(IRS, IRV); /* clear busy, result is ready */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync return rc;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if ( u32Value & HDA_REG_FIELD_FLAG_MASK(IRS, IRV)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync && IRS_IRV(pState))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync IRS(pState) ^= HDA_REG_FIELD_FLAG_MASK(IRS, IRV);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return rc;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync}
56970d3a1944c7c073d66266cd52449835221badvboxsync
56970d3a1944c7c073d66266cd52449835221badvboxsyncDECLCALLBACK(int)hdaRegWriteRIRBWP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
56970d3a1944c7c073d66266cd52449835221badvboxsync{
56970d3a1944c7c073d66266cd52449835221badvboxsync if (u32Value & HDA_REG_FIELD_FLAG_MASK(RIRBWP, RST))
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync RIRBWP(pState) = 0;
56970d3a1944c7c073d66266cd52449835221badvboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*The rest of bits are O, see 6.2.22 */
56970d3a1944c7c073d66266cd52449835221badvboxsync return VINF_SUCCESS;
56970d3a1944c7c073d66266cd52449835221badvboxsync}
56970d3a1944c7c073d66266cd52449835221badvboxsync
56970d3a1944c7c073d66266cd52449835221badvboxsyncDECLCALLBACK(int)hdaRegWriteBase(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
56970d3a1944c7c073d66266cd52449835221badvboxsync{
56970d3a1944c7c073d66266cd52449835221badvboxsync int rc = hdaRegWriteU32(pState, offset, index, u32Value);
56970d3a1944c7c073d66266cd52449835221badvboxsync if (RT_FAILURE(rc))
56970d3a1944c7c073d66266cd52449835221badvboxsync AssertRCReturn(rc, rc);
56970d3a1944c7c073d66266cd52449835221badvboxsync switch(index)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync case ICH6_HDA_REG_CORBLBASE:
56970d3a1944c7c073d66266cd52449835221badvboxsync pState->u64CORBBase &= 0xFFFFFFFF00000000ULL;
56970d3a1944c7c073d66266cd52449835221badvboxsync pState->u64CORBBase |= pState->au32Regs[index];
56970d3a1944c7c073d66266cd52449835221badvboxsync break;
56970d3a1944c7c073d66266cd52449835221badvboxsync case ICH6_HDA_REG_CORBUBASE:
56970d3a1944c7c073d66266cd52449835221badvboxsync pState->u64CORBBase &= 0x00000000FFFFFFFFULL;
56970d3a1944c7c073d66266cd52449835221badvboxsync pState->u64CORBBase |= ((uint64_t)pState->au32Regs[index] << 32);
56970d3a1944c7c073d66266cd52449835221badvboxsync break;
56970d3a1944c7c073d66266cd52449835221badvboxsync case ICH6_HDA_REG_RIRLBASE:
56970d3a1944c7c073d66266cd52449835221badvboxsync pState->u64RIRBBase &= 0xFFFFFFFF00000000ULL;
56970d3a1944c7c073d66266cd52449835221badvboxsync pState->u64RIRBBase |= pState->au32Regs[index];
56970d3a1944c7c073d66266cd52449835221badvboxsync break;
56970d3a1944c7c073d66266cd52449835221badvboxsync case ICH6_HDA_REG_RIRUBASE:
56970d3a1944c7c073d66266cd52449835221badvboxsync pState->u64RIRBBase &= 0x00000000FFFFFFFFULL;
56970d3a1944c7c073d66266cd52449835221badvboxsync pState->u64RIRBBase |= ((uint64_t)pState->au32Regs[index] << 32);
56970d3a1944c7c073d66266cd52449835221badvboxsync break;
56970d3a1944c7c073d66266cd52449835221badvboxsync case ICH6_HDA_REG_DPLBASE:
56970d3a1944c7c073d66266cd52449835221badvboxsync /* @todo: first bit has special meaning */
56970d3a1944c7c073d66266cd52449835221badvboxsync pState->u64DPBase &= 0xFFFFFFFF00000000ULL;
56970d3a1944c7c073d66266cd52449835221badvboxsync pState->u64DPBase |= pState->au32Regs[index];
56970d3a1944c7c073d66266cd52449835221badvboxsync break;
56970d3a1944c7c073d66266cd52449835221badvboxsync case ICH6_HDA_REG_DPUBASE:
56970d3a1944c7c073d66266cd52449835221badvboxsync pState->u64DPBase &= 0x00000000FFFFFFFFULL;
56970d3a1944c7c073d66266cd52449835221badvboxsync pState->u64DPBase |= ((uint64_t)pState->au32Regs[index] << 32);
56970d3a1944c7c073d66266cd52449835221badvboxsync break;
56970d3a1944c7c073d66266cd52449835221badvboxsync default:
56970d3a1944c7c073d66266cd52449835221badvboxsync AssertMsgFailed(("Invalid index"));
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync Log(("hda: CORB base:%llx RIRB base: %llx DP base: %llx\n", pState->u64CORBBase, pState->u64RIRBBase, pState->u64DPBase));
56970d3a1944c7c073d66266cd52449835221badvboxsync return rc;
56970d3a1944c7c073d66266cd52449835221badvboxsync}
56970d3a1944c7c073d66266cd52449835221badvboxsync
56970d3a1944c7c073d66266cd52449835221badvboxsyncDECLCALLBACK(int)hdaRegWriteRIRBSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
56970d3a1944c7c073d66266cd52449835221badvboxsync{
56970d3a1944c7c073d66266cd52449835221badvboxsync uint8_t nv = u32Value;
56970d3a1944c7c073d66266cd52449835221badvboxsync uint8_t v = RIRBSTS(pState);
56970d3a1944c7c073d66266cd52449835221badvboxsync RIRBSTS(pState) = (v ^ nv) & v;
56970d3a1944c7c073d66266cd52449835221badvboxsync
56970d3a1944c7c073d66266cd52449835221badvboxsync return hdaProcessInterrupt(pState);
56970d3a1944c7c073d66266cd52449835221badvboxsync}
56970d3a1944c7c073d66266cd52449835221badvboxsync
56970d3a1944c7c073d66266cd52449835221badvboxsyncstatic void dump_bd(INTELHDLinkState *pState, PHDABDLEDESC pBdle, uint64_t u64BaseDMA)
56970d3a1944c7c073d66266cd52449835221badvboxsync{
56970d3a1944c7c073d66266cd52449835221badvboxsync uint64_t addr;
56970d3a1944c7c073d66266cd52449835221badvboxsync uint32_t len;
56970d3a1944c7c073d66266cd52449835221badvboxsync uint32_t ioc;
56970d3a1944c7c073d66266cd52449835221badvboxsync uint8_t bdle[16];
56970d3a1944c7c073d66266cd52449835221badvboxsync uint32_t counter;
56970d3a1944c7c073d66266cd52449835221badvboxsync uint32_t i;
56970d3a1944c7c073d66266cd52449835221badvboxsync uint32_t sum = 0;
56970d3a1944c7c073d66266cd52449835221badvboxsync Assert(pBdle && pBdle->u32BdleMaxCvi);
56970d3a1944c7c073d66266cd52449835221badvboxsync for (i = 0; i <= pBdle->u32BdleMaxCvi; ++i)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(pState), u64BaseDMA + i*16, bdle, 16);
56970d3a1944c7c073d66266cd52449835221badvboxsync addr = *(uint64_t *)bdle;
56970d3a1944c7c073d66266cd52449835221badvboxsync len = *(uint32_t *)&bdle[8];
56970d3a1944c7c073d66266cd52449835221badvboxsync ioc = *(uint32_t *)&bdle[12];
56970d3a1944c7c073d66266cd52449835221badvboxsync Log(("hda: %s bdle[%d] a:%lx, len:%x, ioc:%d\n", (i == pBdle->u32BdleCvi? "[C]": " "), i, addr, len, ioc));
56970d3a1944c7c073d66266cd52449835221badvboxsync sum += len;
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync Log(("hda: sum: %d\n", sum));
56970d3a1944c7c073d66266cd52449835221badvboxsync for (i = 0; i < 8; ++i)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(pState), (pState->u64DPBase & DPBASE_ADDR_MASK) + i*8, &counter, sizeof(&counter));
56970d3a1944c7c073d66266cd52449835221badvboxsync Log(("hda: %s stream[%d] counter=%x\n", i == SDCTL_NUM(pState, 4) || i == SDCTL_NUM(pState, 0)? "[C]": " ",
56970d3a1944c7c073d66266cd52449835221badvboxsync i , counter));
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync}
56970d3a1944c7c073d66266cd52449835221badvboxsyncstatic void fetch_bd(INTELHDLinkState *pState, PHDABDLEDESC pBdle, uint64_t u64BaseDMA)
56970d3a1944c7c073d66266cd52449835221badvboxsync{
56970d3a1944c7c073d66266cd52449835221badvboxsync uint8_t bdle[16];
56970d3a1944c7c073d66266cd52449835221badvboxsync Assert((u64BaseDMA && pBdle && pBdle->u32BdleMaxCvi));
56970d3a1944c7c073d66266cd52449835221badvboxsync PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(pState), u64BaseDMA + pBdle->u32BdleCvi*16, bdle, 16);
56970d3a1944c7c073d66266cd52449835221badvboxsync pBdle->u64BdleCviAddr = *(uint64_t *)bdle;
56970d3a1944c7c073d66266cd52449835221badvboxsync pBdle->u32BdleCviLen = *(uint32_t *)&bdle[8];
56970d3a1944c7c073d66266cd52449835221badvboxsync pBdle->fBdleCviIoc = (*(uint32_t *)&bdle[12]) & 0x1;
56970d3a1944c7c073d66266cd52449835221badvboxsync dump_bd(pState, pBdle, u64BaseDMA);
56970d3a1944c7c073d66266cd52449835221badvboxsync}
56970d3a1944c7c073d66266cd52449835221badvboxsync
56970d3a1944c7c073d66266cd52449835221badvboxsyncstatic uint32_t read_audio(INTELHDLinkState *pState, int avail, bool *fStop)
56970d3a1944c7c073d66266cd52449835221badvboxsync{
56970d3a1944c7c073d66266cd52449835221badvboxsync uint8_t tmpbuf[4096];
56970d3a1944c7c073d66266cd52449835221badvboxsync uint32_t temp;
56970d3a1944c7c073d66266cd52449835221badvboxsync uint32_t u32Rest = 0;
56970d3a1944c7c073d66266cd52449835221badvboxsync uint32_t cbRead = 0;
56970d3a1944c7c073d66266cd52449835221badvboxsync uint32_t to_copy = 0;
56970d3a1944c7c073d66266cd52449835221badvboxsync /* todo: add input line detection */
56970d3a1944c7c073d66266cd52449835221badvboxsync PHDABDLEDESC pBdle = &pState->stInBdle;
56970d3a1944c7c073d66266cd52449835221badvboxsync SWVoiceIn *voice = ISD0FMT_TO_AUDIO_SELECTOR(pState);
56970d3a1944c7c073d66266cd52449835221badvboxsync u32Rest = pBdle->u32BdleCviLen - pBdle->u32BdleCviPos;
56970d3a1944c7c073d66266cd52449835221badvboxsync temp = audio_MIN(u32Rest, (uint32_t)avail);
56970d3a1944c7c073d66266cd52449835221badvboxsync if (!temp)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync *fStop = true;
56970d3a1944c7c073d66266cd52449835221badvboxsync return cbRead;
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync while (temp)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync int copied;
56970d3a1944c7c073d66266cd52449835221badvboxsync to_copy = audio_MIN(temp, 4096U);
56970d3a1944c7c073d66266cd52449835221badvboxsync copied = AUD_read (voice, tmpbuf, to_copy);
56970d3a1944c7c073d66266cd52449835221badvboxsync Log (("hda: read_audio max=%x to_copy=%x copied=%x\n",
56970d3a1944c7c073d66266cd52449835221badvboxsync avail, to_copy, copied));
56970d3a1944c7c073d66266cd52449835221badvboxsync if (!copied)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync *fStop = true;
56970d3a1944c7c073d66266cd52449835221badvboxsync break;
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync PDMDevHlpPhysWrite(ICH6_HDASTATE_2_DEVINS(pState), pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, tmpbuf, copied);
56970d3a1944c7c073d66266cd52449835221badvboxsync temp -= copied;
56970d3a1944c7c073d66266cd52449835221badvboxsync cbRead += copied;
56970d3a1944c7c073d66266cd52449835221badvboxsync pBdle->u32BdleCviPos += copied;
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync return cbRead;
56970d3a1944c7c073d66266cd52449835221badvboxsync}
56970d3a1944c7c073d66266cd52449835221badvboxsyncstatic uint32_t write_audio(INTELHDLinkState *pState, int avail, bool *fStop)
56970d3a1944c7c073d66266cd52449835221badvboxsync{
56970d3a1944c7c073d66266cd52449835221badvboxsync uint8_t tmpbuf[4096];
56970d3a1944c7c073d66266cd52449835221badvboxsync uint32_t temp;
56970d3a1944c7c073d66266cd52449835221badvboxsync uint32_t u32Rest;
56970d3a1944c7c073d66266cd52449835221badvboxsync uint32_t written = 0;
56970d3a1944c7c073d66266cd52449835221badvboxsync int to_copy = 0;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync PHDABDLEDESC pBdle = &pState->stOutBdle;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync u32Rest = pBdle->u32BdleCviLen - pBdle->u32BdleCviPos;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync temp = audio_MIN(u32Rest, (uint32_t)avail);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (!temp)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync *fStop = true;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return written;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync while (temp)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync int copied;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync to_copy = audio_MIN(temp, 4096U);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(pState), pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, tmpbuf, to_copy);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync copied = AUD_write (OSD0FMT_TO_AUDIO_SELECTOR(pState), tmpbuf, to_copy);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Log (("hda: write_audio max=%x to_copy=%x copied=%x\n",
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync avail, to_copy, copied));
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Assert((copied));
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (!copied)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync *fStop = true;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync temp -= copied;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync written += copied;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync pBdle->u32BdleCviPos += copied;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return written;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync}
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncDECLCALLBACK(int) hdaCodecReset(CODECState *pCodecState)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync{
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync INTELHDLinkState *pState = (INTELHDLinkState *)pCodecState->pHDAState;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return VINF_SUCCESS;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync}
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsyncDECLCALLBACK(void) hdaTransfer(CODECState *pCodecState, ENMSOUNDSOURCE src, int avail)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync{
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync bool fStop = false;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync uint64_t u64BaseDMA = 0;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync PHDABDLEDESC pBdle = NULL;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync INTELHDLinkState *pState = (INTELHDLinkState *)pCodecState->pHDAState;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync uint32_t nBytes;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync uint32_t u32Ctl;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync uint32_t *pu32Sts;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync uint8_t u8Strm;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync uint32_t *pu32Lpib;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync uint32_t u32Lcbl;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync switch (src)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case PO_INDEX:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync u8Strm = 4;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync u32Ctl = SDCTL(pState, 4);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync u64BaseDMA = SDBDPL(pState, 4);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync u64BaseDMA |= (((uint64_t)SDBDPU(pState, 4)) << 32);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync pu32Lpib = &SDLPIB(pState, 4);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync pu32Sts = &SDSTS(pState, 4);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync u32Lcbl = SDLCBL(pState, 4);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync pBdle = &pState->stOutBdle;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync pBdle->u32BdleMaxCvi = SDLVI(pState, 4);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case PI_INDEX:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync u8Strm = 0;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync u32Ctl = SDCTL(pState, 0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync pu32Lpib = &SDLPIB(pState, 0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync pu32Sts = &SDSTS(pState, 0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync u32Lcbl = SDLCBL(pState, 0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync u64BaseDMA = SDBDPL(pState, 0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync u64BaseDMA |= (((uint64_t)SDBDPU(pState, 0)) << 32);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync pBdle = &pState->stInBdle;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync pBdle->u32BdleMaxCvi = SDLVI(pState, 0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync default:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if ( !(u32Ctl & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync || !avail
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync || !u64BaseDMA)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* Fetch the Buffer Descriptor Entry (BDE). */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync fetch_bd(pState, pBdle, u64BaseDMA);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync while( avail && !fStop)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync switch (src)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case PO_INDEX:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync nBytes = write_audio(pState, avail, &fStop);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case PI_INDEX:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync nBytes = read_audio(pState, avail, &fStop);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync default:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync nBytes = 0;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync fStop = true;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync AssertMsgFailed(("Unsupported"));
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* Update the buffer position and handle Cyclic Buffer Length (CBL) wraparound. */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync *pu32Lpib += nBytes;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync avail -= nBytes;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (*pu32Lpib >= u32Lcbl)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync *pu32Lpib -= u32Lcbl;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* Optionally write back the current DMA position. */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (pState->u64DPBase & DPBASE_ENABLED)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync PDMDevHlpPhysWrite(ICH6_HDASTATE_2_DEVINS(pState),
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync (pState->u64DPBase & DPBASE_ADDR_MASK) + u8Strm*8, pu32Lpib, sizeof(*pu32Lpib));
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* Process end of buffer condition. */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (pBdle->u32BdleCviPos == pBdle->u32BdleCviLen)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (pBdle->fBdleCviIoc)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync *pu32Sts |= HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hdaProcessInterrupt(pState);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync pBdle->u32BdleCviPos = 0;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync pBdle->u32BdleCvi++;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync if (pBdle->u32BdleCvi == pBdle->u32BdleMaxCvi + 1)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync {
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync pBdle->u32BdleCvi = 0;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync fStop = true; /* Give the guest a chance to refill (or empty) buffers. */
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync}
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync/**
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync * Handle register read operation.
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync *
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync * Looks up and calls appropriate handler.
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync *
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync * @note: while implementation was detected so called "forgotten" or "hole" registers
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync * which description is missed in RPM, datasheet or spec.
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync *
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync * @returns VBox status code.
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync *
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync * @param pState The device state structure.
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync * @param uOffset Register offset in memory-mapped frame.
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync * @param pv Where to fetch the value.
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync * @param cb Number of bytes to write.
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync * @thread EMT
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync */
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsyncPDMBOTHCBDECL(int) hdaMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync{
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync int rc = VINF_SUCCESS;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync uint32_t u32Offset = GCPhysAddr - pThis->hda.addrMMReg;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync int index = hdaLookup(&pThis->hda, u32Offset);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync if (pThis->hda.fInReset && index != ICH6_HDA_REG_GCTL)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync {
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync Log(("hda: access to registers except GCTL is blocked while reset\n"));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Assert( index != -1
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync && cb <= 4);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (index != -1)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync uint32_t mask = 0;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync uint32_t shift = (u32Offset - s_ichIntelHDRegMap[index].offset) % sizeof(uint32_t) * 8;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync uint32_t v = 0;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync switch(cb)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case 1: mask = 0x000000ff; break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case 2: mask = 0x0000ffff; break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case 3: mask = 0x00ffffff; break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case 4: mask = 0xffffffff; break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync mask <<= shift;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync rc = s_ichIntelHDRegMap[index].pfnRead(&pThis->hda, u32Offset, index, &v);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync *(uint32_t *)pv = (v & mask) >> shift;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Log(("hda: read %s[%x/%x]\n", s_ichIntelHDRegMap[index].abbrev, v, *(uint32_t *)pv));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync return rc;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync *(uint32_t *)pv = 0xFF;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Log(("hda: hole at %X is accessed for read\n", u32Offset));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync return rc;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync}
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync/**
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * Handle register write operation.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync *
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * Looks up and calls appropriate handler.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync *
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @returns VBox status code.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync *
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @param pState The device state structure.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @param uOffset Register offset in memory-mapped frame.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @param pv Where to fetch the value.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @param cb Number of bytes to write.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @thread EMT
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsyncPDMBOTHCBDECL(int) hdaMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync{
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync int rc = VINF_SUCCESS;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync uint32_t u32Offset = GCPhysAddr - pThis->hda.addrMMReg;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync int index = hdaLookup(&pThis->hda, u32Offset);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (pThis->hda.fInReset && index != ICH6_HDA_REG_GCTL)
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync {
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync Log(("hda: access to registers except GCTL is blocked while reset\n"));
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync Assert( index != -1
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync && cb <= 4);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (index != -1)
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint32_t v = pThis->hda.au32Regs[index];
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync uint32_t mask = 0;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync uint32_t shift = (u32Offset - s_ichIntelHDRegMap[index].offset) % sizeof(uint32_t) * 8;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync switch(cb)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case 1: mask = 0xffffff00; break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case 2: mask = 0xffff0000; break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case 3: mask = 0xff000000; break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case 4: mask = 0x00000000; break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync mask <<= shift;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync *(uint32_t *)pv = ((v & mask) | (*(uint32_t *)pv & ~mask)) >> shift;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync rc = s_ichIntelHDRegMap[index].pfnWrite(&pThis->hda, u32Offset, index, *(uint32_t *)pv);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Log(("hda: write %s:(%x) %x => %x\n", s_ichIntelHDRegMap[index].abbrev, *(uint32_t *)pv, v, pThis->hda.au32Regs[index]));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync return rc;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Log(("hda: hole at %X is accessed for write\n", u32Offset));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync return rc;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync}
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync/**
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * Callback function for mapping a PCI I/O region.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync *
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @return VBox status code.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @param pPciDev Pointer to PCI device.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * Use pPciDev->pDevIns to get the device instance.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @param iRegion The region number.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @param GCPhysAddress Physical address of the region.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * If iType is PCI_ADDRESS_SPACE_IO, this is an
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * I/O port, else it's a physical address.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * This address is *NOT* relative
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * to pci_mem_base like earlier!
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @param enmType One of the PCI_ADDRESS_SPACE_* values.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsyncstatic DECLCALLBACK(int) hdaMap (PPCIDEVICE pPciDev, int iRegion,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTGCPHYS GCPhysAddress, uint32_t cb,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync PCIADDRESSSPACE enmType)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync{
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync int rc;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync PPDMDEVINS pDevIns = pPciDev->pDevIns;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTIOPORT Port = (RTIOPORT)GCPhysAddress;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync PCIINTELHDLinkState *pThis = PCIDEV_2_ICH6_HDASTATE(pPciDev);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Assert(enmType == PCI_ADDRESS_SPACE_MEM);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync rc = PDMDevHlpMMIORegister(pPciDev->pDevIns, GCPhysAddress, cb, 0,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync hdaMMIOWrite, hdaMMIORead, NULL, "ICH6_HDA");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (RT_FAILURE(rc))
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync return rc;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pThis->hda.addrMMReg = GCPhysAddress;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync return VINF_SUCCESS;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync}
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync/**
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * Saves a state of the HDA device.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync *
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @returns VBox status code.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @param pDevIns The device instance.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @param pSSMHandle The handle to save the state to.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsyncstatic DECLCALLBACK(int) hdaSaveExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync{
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* Save Codec nodes states */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync codecSaveState(&pThis->hda.Codec, pSSMHandle);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* Save MMIO registers */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SSMR3PutMem (pSSMHandle, pThis->hda.au32Regs, sizeof (pThis->hda.au32Regs));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* Save HDA dma counters */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SSMR3PutMem (pSSMHandle, &pThis->hda.stOutBdle, sizeof (HDABDLEDESC));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SSMR3PutMem (pSSMHandle, &pThis->hda.stMicBdle, sizeof (HDABDLEDESC));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SSMR3PutMem (pSSMHandle, &pThis->hda.stInBdle, sizeof (HDABDLEDESC));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync return VINF_SUCCESS;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync}
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync/**
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * Loads a saved HDA device state.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync *
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @returns VBox status code.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @param pDevIns The device instance.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @param pSSMHandle The handle to the saved state.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @param uVersion The data unit version number.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @param uPass The data pass.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsyncstatic DECLCALLBACK(int) hdaLoadExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync uint32_t uVersion, uint32_t uPass)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync{
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* Load Codec nodes states */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync AssertMsgReturn (uVersion == HDA_SSM_VERSION, ("%d\n", uVersion), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Assert (uPass == SSM_PASS_FINAL); NOREF(uPass);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync codecLoadState(&pThis->hda.Codec, pSSMHandle);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* Load MMIO registers */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SSMR3GetMem (pSSMHandle, pThis->hda.au32Regs, sizeof (pThis->hda.au32Regs));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* Load HDA dma counters */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SSMR3GetMem (pSSMHandle, &pThis->hda.stOutBdle, sizeof (HDABDLEDESC));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SSMR3GetMem (pSSMHandle, &pThis->hda.stMicBdle, sizeof (HDABDLEDESC));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SSMR3GetMem (pSSMHandle, &pThis->hda.stInBdle, sizeof (HDABDLEDESC));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync AUD_set_active_in(ISD0FMT_TO_AUDIO_SELECTOR(&pThis->hda), SDCTL(&pThis->hda, 0) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync AUD_set_active_out(OSD0FMT_TO_AUDIO_SELECTOR(&pThis->hda), SDCTL(&pThis->hda, 4) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pThis->hda.u64CORBBase = CORBLBASE(&pThis->hda);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pThis->hda.u64CORBBase |= ((uint64_t)CORBUBASE(&pThis->hda)) << 32;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pThis->hda.u64RIRBBase = RIRLBASE(&pThis->hda);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pThis->hda.u64RIRBBase |= ((uint64_t)RIRUBASE(&pThis->hda)) << 32;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pThis->hda.u64DPBase = DPLBASE(&pThis->hda);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pThis->hda.u64DPBase |= ((uint64_t)DPUBASE(&pThis->hda)) << 32;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync return VINF_SUCCESS;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync}
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync/**
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * Reset notification.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync *
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @returns VBox status.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @param pDevIns The device instance data.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync *
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @remark The original sources didn't install a reset handler, but it seems to
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * make sense to me so we'll do it.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsyncstatic DECLCALLBACK(void) hdaReset (PPDMDEVINS pDevIns)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync{
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync GCAP(&pThis->hda) = 0x4401; /* see 6.2.1 */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync VMIN(&pThis->hda) = 0x00; /* see 6.2.2 */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync VMAJ(&pThis->hda) = 0x01; /* see 6.2.3 */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync VMAJ(&pThis->hda) = 0x01; /* see 6.2.3 */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync OUTPAY(&pThis->hda) = 0x003C; /* see 6.2.4 */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync INPAY(&pThis->hda) = 0x001D; /* see 6.2.5 */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pThis->hda.au32Regs[ICH6_HDA_REG_CORBSIZE] = 0x42; /* see 6.2.1 */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pThis->hda.au32Regs[ICH6_HDA_REG_RIRBSIZE] = 0x42; /* see 6.2.1 */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CORBRP(&pThis->hda) = 0x0;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RIRBWP(&pThis->hda) = 0x0;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync LogRel(("hda: inter HDA reset.\n"));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync //** @todo r=michaln: There should be LogRel statements when the guest initializes
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync // or resets the HDA chip, and possibly also when opening the PCM streams.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pThis->hda.cbCorbBuf = 256 * sizeof(uint32_t);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (pThis->hda.pu32CorbBuf)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync memset(pThis->hda.pu32CorbBuf, 0, pThis->hda.cbCorbBuf);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pThis->hda.pu32CorbBuf = (uint32_t *)RTMemAllocZ(pThis->hda.cbCorbBuf);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pThis->hda.cbRirbBuf = 256 * sizeof(uint64_t);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (pThis->hda.pu64RirbBuf)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync memset(pThis->hda.pu64RirbBuf, 0, pThis->hda.cbRirbBuf);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pThis->hda.pu64RirbBuf = (uint64_t *)RTMemAllocZ(pThis->hda.cbRirbBuf);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* Accoding to ICH6 datasheet, 0x40000 is default value for stream descriptor register 23:20
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * bits are reserved for stream number 18.2.33 */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SDCTL(&pThis->hda, 0) = 0x40000;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SDCTL(&pThis->hda, 1) = 0x40000;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SDCTL(&pThis->hda, 2) = 0x40000;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SDCTL(&pThis->hda, 3) = 0x40000;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SDCTL(&pThis->hda, 4) = 0x40000;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SDCTL(&pThis->hda, 5) = 0x40000;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SDCTL(&pThis->hda, 6) = 0x40000;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SDCTL(&pThis->hda, 7) = 0x40000;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* ICH6 defines default values (0x77 for input and 0xBF for output descriptors) of FIFO size. 18.2.39 */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SDFIFOS(&pThis->hda, 0) = 0x77;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SDFIFOS(&pThis->hda, 1) = 0x77;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SDFIFOS(&pThis->hda, 2) = 0x77;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SDFIFOS(&pThis->hda, 3) = 0x77;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SDFIFOS(&pThis->hda, 4) = 0xBF;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SDFIFOS(&pThis->hda, 5) = 0xBF;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SDFIFOS(&pThis->hda, 6) = 0xBF;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync SDFIFOS(&pThis->hda, 7) = 0xBF;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* emulateion of codec "wake up" HDA spec (5.5.1 and 6.5)*/
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync STATESTS(&pThis->hda) = 0x1;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Log(("hda: reset finished\n"));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync}
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync/**
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @interface_method_impl{PDMIBASE,pfnQueryInterface}
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsyncstatic DECLCALLBACK(void *) hdaQueryInterface (struct PDMIBASE *pInterface,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync const char *pszIID)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync{
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync PCIINTELHDLinkState *pThis = RT_FROM_MEMBER(pInterface, PCIINTELHDLinkState, hda.IBase);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Assert(&pThis->hda.IBase == pInterface);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->hda.IBase);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync return NULL;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync}
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync//#define HDA_AS_PCI_EXPRESS
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync/**
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * @interface_method_impl{PDMDEVREG,pfnConstruct}
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsyncstatic DECLCALLBACK(int) hdaConstruct (PPDMDEVINS pDevIns, int iInstance,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync PCFGMNODE pCfgHandle)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync{
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync INTELHDLinkState *s = &pThis->hda;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync int rc;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Assert(iInstance == 0);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /*
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync * Validations.
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (!CFGMR3AreValuesValid (pCfgHandle, "\0"))
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync return PDMDEV_SET_ERROR (pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync N_ ("Invalid configuration for the INTELHD device"));
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync // ** @todo r=michaln: This device may need R0/RC enabling, especially if guests
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync // poll some register(s).
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /*
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync * Initialize data (most of it anyway).
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync s->pDevIns = pDevIns;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* IBase */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync s->IBase.pfnQueryInterface = hdaQueryInterface;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* PCI Device (the assertions will be removed later) */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync#if defined(VBOX_WITH_HP_HDA)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Linux kernel has whitelist for MSI-enabled HDA, this card seems to be there. */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetVendorId (&pThis->dev, 0x103c); /* HP. */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetDeviceId (&pThis->dev, 0x30f7); /* HP Pavilion dv4t-1300 */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync#elif defined(VBOX_WITH_INTEL_HDA)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetVendorId (&pThis->dev, 0x8086); /* 00 ro - intel. */
f40cc8247b1da75ce42e73e6c557ec29b8f830a5vboxsync PCIDevSetDeviceId (&pThis->dev, 0x2668); /* 02 ro - 82801 / 82801aa(?). */
f40cc8247b1da75ce42e73e6c557ec29b8f830a5vboxsync#elif defined(VBOX_WITH_NVIDIA_HDA)
f40cc8247b1da75ce42e73e6c557ec29b8f830a5vboxsync PCIDevSetVendorId (&pThis->dev, 0x10de); /* nVidia */
f40cc8247b1da75ce42e73e6c557ec29b8f830a5vboxsync PCIDevSetDeviceId (&pThis->dev, 0x0ac0); /* HDA */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync#else
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync# error "Please specify your HDA device vendor/device IDs"
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync#endif
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetCommand (&pThis->dev, 0x0000); /* 04 rw,ro - pcicmd. */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetStatus (&pThis->dev, VBOX_PCI_STATUS_CAP_LIST); /* 06 rwc?,ro? - pcists. */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetRevisionId (&pThis->dev, 0x01); /* 08 ro - rid. */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetClassProg (&pThis->dev, 0x00); /* 09 ro - pi. */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetClassSub (&pThis->dev, 0x03); /* 0a ro - scc; 03 == HDA. */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetClassBase (&pThis->dev, 0x04); /* 0b ro - bcc; 04 == multimedia. */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetHeaderType (&pThis->dev, 0x00); /* 0e ro - headtyp. */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetBaseAddress (&pThis->dev, 0, /* 10 rw - MMIO */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync false /* fIoSpace */, false /* fPrefetchable */, true /* f64Bit */, 0x00000000);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetInterruptLine (&pThis->dev, 0x00); /* 3c rw. */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetInterruptPin (&pThis->dev, 0x01); /* 3d ro - INTA#. */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync#if defined(HDA_AS_PCI_EXPRESS)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetCapabilityList (&pThis->dev, 0x80);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync#elif defined(VBOX_WITH_MSI_DEVICES)
f40cc8247b1da75ce42e73e6c557ec29b8f830a5vboxsync PCIDevSetCapabilityList (&pThis->dev, 0x60);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync#else
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetCapabilityList (&pThis->dev, 0x50); /* ICH6 datasheet 18.1.16 */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync#endif
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync //** @todo r=michaln: If there are really no PCIDevSetXx for these, the meaning
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync // of these values needs to be properly documented!
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* HDCTL off 0x40 bit 0 selects signaling mode (1-HDA, 0 - Ac97) 18.1.19 */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetByte(&pThis->dev, 0x40, 0x01);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Power Management */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetByte(&pThis->dev, 0x50 + 0, VBOX_PCI_CAP_ID_PM);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetByte(&pThis->dev, 0x50 + 1, 0x0); /* next */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetWord(&pThis->dev, 0x50 + 2, VBOX_PCI_PM_CAP_DSI | 0x02 /* version, PM1.1 */ );
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync#ifdef HDA_AS_PCI_EXPRESS
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* PCI Express */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetByte (&pThis->dev, 0x80 + 0, VBOX_PCI_CAP_ID_EXP); /* PCI_Express */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetByte (&pThis->dev, 0x80 + 1, 0x60); /* next */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Device flags */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetWord (&pThis->dev, 0x80 + 2,
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* version */ 0x1 |
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Root Complex Integrated Endpoint */ (VBOX_PCI_EXP_TYPE_ROOT_INT_EP << 4) |
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* MSI */ (100) << 9
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync );
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Device capabilities */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetDWord (&pThis->dev, 0x80 + 4, VBOX_PCI_EXP_DEVCAP_FLRESET);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Device control */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetWord (&pThis->dev, 0x80 + 8, 0);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Device status */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetWord (&pThis->dev, 0x80 + 10, 0);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Link caps */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetDWord (&pThis->dev, 0x80 + 12, 0);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Link control */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetWord (&pThis->dev, 0x80 + 16, 0);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Link status */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetWord (&pThis->dev, 0x80 + 18, 0);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /* Slot capabilities */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync PCIDevSetDWord (&pThis->dev, 0x80 + 20, 0);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /* Slot control */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetWord (&pThis->dev, 0x80 + 24, 0);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Slot status */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetWord (&pThis->dev, 0x80 + 26, 0);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Root control */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetWord (&pThis->dev, 0x80 + 28, 0);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Root capabilities */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetWord (&pThis->dev, 0x80 + 30, 0);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Root status */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetDWord (&pThis->dev, 0x80 + 32, 0);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Device capabilities 2 */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetDWord (&pThis->dev, 0x80 + 36, 0);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Device control 2 */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetQWord (&pThis->dev, 0x80 + 40, 0);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Link control 2 */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetQWord (&pThis->dev, 0x80 + 48, 0);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Slot control 2 */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetWord (&pThis->dev, 0x80 + 56, 0);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync#endif
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /*
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync * Register the PCI device.
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync rc = PDMDevHlpPCIRegister (pDevIns, &pThis->dev);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (RT_FAILURE (rc))
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync return rc;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync rc = PDMDevHlpPCIIORegionRegister (pDevIns, 0, 0x4000, PCI_ADDRESS_SPACE_MEM,
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync hdaMap);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (RT_FAILURE (rc))
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync return rc;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync#ifdef VBOX_WITH_MSI_DEVICES
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PDMMSIREG aMsiReg;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync RT_ZERO(aMsiReg);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync aMsiReg.cMsiVectors = 1;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync aMsiReg.iMsiCapOffset = 0x60;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync aMsiReg.iMsiNextOffset = 0x50;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync rc = PDMDevHlpPCIRegisterMsi(pDevIns, &aMsiReg);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (RT_FAILURE (rc))
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync {
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync LogRel(("Chipset cannot do MSI: %Rrc\n", rc));
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync PCIDevSetCapabilityList (&pThis->dev, 0x50);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync }
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync#endif
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync rc = PDMDevHlpSSMRegister (pDevIns, HDA_SSM_VERSION, sizeof(*pThis), hdaSaveExec, hdaLoadExec);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (RT_FAILURE (rc))
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync return rc;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /*
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync * Attach driver.
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync rc = PDMDevHlpDriverAttach (pDevIns, 0, &s->IBase,
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync &s->pDrvBase, "Audio Driver Port");
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync Log (("hda: No attached driver!\n"));
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync else if (RT_FAILURE (rc))
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync {
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync AssertMsgFailed (("Failed to attach INTELHD LUN #0! rc=%Rrc\n", rc));
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync return rc;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync pThis->hda.Codec.pHDAState = (void *)&pThis->hda;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync rc = codecConstruct(&pThis->hda.Codec, /* ALC885_CODEC */ STAC9220_CODEC);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (RT_FAILURE(rc))
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync AssertRCReturn(rc, rc);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /* ICH6 datasheet defines 0 values for SVID and SID (18.1.14-15), which together with values returned for
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync verb F20 should provide device/codec recognition. */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync Assert(pThis->hda.Codec.u16VendorId);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync Assert(pThis->hda.Codec.u16DeviceId);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync PCIDevSetSubSystemVendorId (&pThis->dev, pThis->hda.Codec.u16VendorId); /* 2c ro - intel.) */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync PCIDevSetSubSystemId (&pThis->dev, pThis->hda.Codec.u16DeviceId); /* 2e ro. */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync hdaReset (pDevIns);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync pThis->hda.Codec.id = 0;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync pThis->hda.Codec.pfnTransfer = hdaTransfer;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync pThis->hda.Codec.pfnReset = hdaCodecReset;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /*
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync * 18.2.6,7 defines that values of this registers might be cleared on power on/reset
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync * hdaReset shouldn't affects these registers.
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync WAKEEN(&pThis->hda) = 0x0;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync STATESTS(&pThis->hda) = 0x0;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync return VINF_SUCCESS;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync}
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync/**
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync * @interface_method_impl{PDMDEVREG,pfnDestruct}
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsyncstatic DECLCALLBACK(int) hdaDestruct (PPDMDEVINS pDevIns)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync{
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync int rc = codecDestruct(&pThis->hda.Codec);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync AssertRC(rc);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (pThis->hda.pu32CorbBuf)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync RTMemFree(pThis->hda.pu32CorbBuf);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (pThis->hda.pu64RirbBuf)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync RTMemFree(pThis->hda.pu64RirbBuf);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync return VINF_SUCCESS;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync}
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync/**
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync * The device registration structure.
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsyncconst PDMDEVREG g_DeviceICH6_HDA =
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync{
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /* u32Version */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync PDM_DEVREG_VERSION,
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /* szName */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync "hda",
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /* szRCMod */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync "",
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /* szR0Mod */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync "",
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /* pszDescription */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync "ICH IntelHD Audio Controller",
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /* fFlags */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync PDM_DEVREG_FLAGS_DEFAULT_BITS,
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /* fClass */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync PDM_DEVREG_CLASS_AUDIO,
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /* cMaxInstances */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync 1,
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /* cbInstance */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync sizeof(PCIINTELHDLinkState),
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /* pfnConstruct */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync hdaConstruct,
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /* pfnDestruct */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync hdaDestruct,
8f7ee9e453c60b3b699799538a45950b35266665vboxsync /* pfnRelocate */
8f7ee9e453c60b3b699799538a45950b35266665vboxsync NULL,
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync /* pfnIOCtl */
8f7ee9e453c60b3b699799538a45950b35266665vboxsync NULL,
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync /* pfnPowerOn */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync NULL,
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync /* pfnReset */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync hdaReset,
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync /* pfnSuspend */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync NULL,
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync /* pfnResume */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync NULL,
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync /* pfnAttach */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync NULL,
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync /* pfnDetach */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync NULL,
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync /* pfnQueryInterface. */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync NULL,
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync /* pfnInitComplete */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync NULL,
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync /* pfnPowerOff */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync NULL,
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync /* pfnSoftReset */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync NULL,
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync /* u32VersionEnd */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync PDM_DEVREG_VERSION
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync};
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync