VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/HDAStreamPeriod.h@ 76553

Last change on this file since 76553 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1/* $Id: HDAStreamPeriod.h 76553 2019-01-01 01:45:53Z vboxsync $ */
2/** @file
3 * HDAStreamPeriod.h - Stream period functions for HD Audio.
4 */
5
6/*
7 * Copyright (C) 2017-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef HDA_STREAMPERIOD_H
19#define HDA_STREAMPERIOD_H
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <iprt/critsect.h>
25#ifdef DEBUG
26# include <iprt/time.h>
27#endif
28#include <VBox/log.h> /* LOG_ENABLED */
29
30struct HDASTREAM;
31typedef HDASTREAM *PHDASTREAM;
32
33#ifdef LOG_ENABLED
34/**
35 * Structure for debug information of an HDA stream's period.
36 */
37typedef struct HDASTREAMPERIODDBGINFO
38{
39 /** Host start time (in ns) of the period. */
40 uint64_t tsStartNs;
41} HDASTREAMPERIODDBGINFO, *PHDASTREAMPERIODDBGINFO;
42#endif
43
44/** No flags set. */
45#define HDASTREAMPERIOD_FLAG_NONE 0
46/** The stream period has been initialized and is in a valid state. */
47#define HDASTREAMPERIOD_FLAG_VALID RT_BIT(0)
48/** The stream period is active. */
49#define HDASTREAMPERIOD_FLAG_ACTIVE RT_BIT(1)
50
51/**
52 * Structure for keeping an HDA stream's (time) period.
53 * This is needed in order to keep track of stream timing and interrupt delivery.
54 */
55typedef struct HDASTREAMPERIOD
56{
57 /** Critical section for serializing access. */
58 RTCRITSECT CritSect;
59 /** Associated HDA stream descriptor (SD) number. */
60 uint8_t u8SD;
61 /** The period's status flags. */
62 uint8_t fStatus;
63 /** Number of pending interrupts required for this period. */
64 uint8_t cIntPending;
65 uint8_t bPadding0;
66 /** Hertz (Hz) rate this period runs with. */
67 uint32_t u32Hz;
68 /** Period start time (in wall clock counts). */
69 uint64_t u64StartWalClk;
70 /** Period duration (in wall clock counts). */
71 uint64_t u64DurationWalClk;
72 /** The period's (relative) elapsed time (in wall clock counts). */
73 uint64_t u64ElapsedWalClk;
74 /** Delay (in wall clock counts) for tweaking the period timing. Optional. */
75 int64_t i64DelayWalClk;
76 /** Number of audio frames to transfer for this period. */
77 uint32_t framesToTransfer;
78 /** Number of audio frames already transfered. */
79 uint32_t framesTransferred;
80#ifdef LOG_ENABLED
81 /** Debugging information. */
82 HDASTREAMPERIODDBGINFO Dbg;
83#endif
84} HDASTREAMPERIOD;
85AssertCompileSizeAlignment(HDASTREAMPERIOD, 8);
86/** Pointer to a HDA stream's time period keeper. */
87typedef HDASTREAMPERIOD *PHDASTREAMPERIOD;
88
89#ifdef IN_RING3
90int hdaR3StreamPeriodCreate(PHDASTREAMPERIOD pPeriod);
91void hdaR3StreamPeriodDestroy(PHDASTREAMPERIOD pPeriod);
92int hdaR3StreamPeriodInit(PHDASTREAMPERIOD pPeriod, uint8_t u8SD, uint16_t u16LVI, uint32_t u32CBL, PPDMAUDIOSTREAMCFG pStreamCfg);
93void hdaR3StreamPeriodReset(PHDASTREAMPERIOD pPeriod);
94int hdaR3StreamPeriodBegin(PHDASTREAMPERIOD pPeriod, uint64_t u64WalClk);
95void hdaR3StreamPeriodEnd(PHDASTREAMPERIOD pPeriod);
96void hdaR3StreamPeriodPause(PHDASTREAMPERIOD pPeriod);
97void hdaR3StreamPeriodResume(PHDASTREAMPERIOD pPeriod);
98bool hdaR3StreamPeriodLock(PHDASTREAMPERIOD pPeriod);
99void hdaR3StreamPeriodUnlock(PHDASTREAMPERIOD pPeriod);
100uint64_t hdaR3StreamPeriodFramesToWalClk(PHDASTREAMPERIOD pPeriod, uint32_t uFrames);
101uint64_t hdaR3StreamPeriodGetAbsEndWalClk(PHDASTREAMPERIOD pPeriod);
102uint64_t hdaR3StreamPeriodGetAbsElapsedWalClk(PHDASTREAMPERIOD pPeriod);
103uint32_t hdaR3StreamPeriodGetRemainingFrames(PHDASTREAMPERIOD pPeriod);
104bool hdaR3StreamPeriodHasElapsed(PHDASTREAMPERIOD pPeriod);
105bool hdaR3StreamPeriodHasPassedAbsWalClk(PHDASTREAMPERIOD pPeriod, uint64_t u64WalClk);
106bool hdaR3StreamPeriodNeedsInterrupt(PHDASTREAMPERIOD pPeriod);
107void hdaR3StreamPeriodAcquireInterrupt(PHDASTREAMPERIOD pPeriod);
108void hdaR3StreamPeriodReleaseInterrupt(PHDASTREAMPERIOD pPeriod);
109void hdaR3StreamPeriodInc(PHDASTREAMPERIOD pPeriod, uint32_t framesInc);
110bool hdaR3StreamPeriodIsComplete(PHDASTREAMPERIOD pPeriod);
111#endif /* IN_RING3 */
112
113#endif /* !HDA_STREAMPERIOD_H */
114
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette