1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
|
/****************************************************************************
HalRecordMix.cpp
Description: Lynx Application Programming Interface Header File
Created: David A. Hoatson, September 2000
Copyright 2000 Lynx Studio Technology, Inc.
This software contains the valuable TRADE SECRETS and CONFIDENTIAL INFORMATION
of Lynx Studio Technology, Inc. The software is protected under copyright
laws as an unpublished work of Lynx Studio Technology, Inc. Notice is
for informational purposes only and does not imply publication. The user
of this software may make copies of the software for use with products
manufactured by Lynx Studio Technology, Inc. or under license from
Lynx Studio Technology, Inc. and for no other use.
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
PURPOSE.
Environment:
4 spaces per tab
Revision History
When Who Description
--------- --- ------------------------------------------------------------
****************************************************************************/
#include <StdAfx.h>
#include "HalAdapter.h"
/////////////////////////////////////////////////////////////////////////////
USHORT
CHalRecordMix::Open (PHALADAPTER pHalAdapter, PULONG pRecordMixCtl,
PULONG pRecordMixStatus)
/////////////////////////////////////////////////////////////////////////////
{
//cmn_err((CE_WARN,"CHalRecordMix::Open\n"));
m_pHalAdapter = pHalAdapter;
m_RegMixControl.Init (m_pHalAdapter, pRecordMixCtl);
m_RegMixStatus.Init (m_pHalAdapter, pRecordMixStatus);
m_bHasPMixV3 = m_pHalAdapter->HasPMixV3 (); // Shadow this so we don't have to keep looking it up
m_asSource = 0;
SetMute (FALSE);
m_usDitherDepth = 24;
SetDitherDepth (MIXVAL_DITHERDEPTH_AUTO);
SetDither (TRUE);
return (HSTATUS_OK);
}
/////////////////////////////////////////////////////////////////////////////
ULONG
CHalRecordMix::GetLevel ()
/////////////////////////////////////////////////////////////////////////////
{
ULONG ulLevel = m_RegMixStatus.Read () & REG_RMIXSTAT_LEVEL_MASK;
if (ulLevel > 0x7FFFF)
ulLevel = 0x7FFFF;
return (ulLevel);
}
/////////////////////////////////////////////////////////////////////////////
void
CHalRecordMix::ResetLevel ()
/////////////////////////////////////////////////////////////////////////////
{
if (!m_bHasPMixV3)
{
m_RegMixStatus.BitSet (REG_RMIXSTAT_LEVEL_RESET, TRUE);
}
}
/////////////////////////////////////////////////////////////////////////////
void
CHalRecordMix::SetSource (USHORT usSource)
/////////////////////////////////////////////////////////////////////////////
{
//cmn_err((CE_WARN,"CHalRecordMix::SetSource\n"));
ULONG ulSource = usSource & REG_RMIX_INSRC_MASK_V3;
if (m_bHasPMixV3)
{
//ulSource 0..31 then 64..111 are valid
if (ulSource > 31)
ulSource += 32; // 32 == 64, 32-64
}
else if (m_pHalAdapter->IsLynxTWO ())
{
if (ulSource > 7)
ulSource += 24; // 8 == 32
}
else // AES16 / AES16e
{
if (ulSource > 15)
ulSource += 16; // 16 == 32, 32-47
}
if (m_bHasPMixV3)
m_RegMixControl.Write (ulSource, REG_RMIX_INSRC_MASK_V3);
else
m_RegMixControl.Write (ulSource, REG_RMIX_INSRC_MASK);
m_asSource = usSource;
}
/////////////////////////////////////////////////////////////////////////////
void
CHalRecordMix::SetMute (BOOLEAN bMute)
/////////////////////////////////////////////////////////////////////////////
{
m_bMute = bMute ? TRUE : FALSE;
m_RegMixControl.BitSet (REG_RMIX_MUTE, m_bMute);
}
/////////////////////////////////////////////////////////////////////////////
void
CHalRecordMix::SetDitherDepth (USHORT usDitherDepth)
// Input is either from Application trying to set dither depth or from
// driver trying to inform us of the bit depth
/////////////////////////////////////////////////////////////////////////////
{
//cmn_err((CE_WARN,"CHalRecordMix::SetDitherDepth %u\n", usDitherDepth ));
// if this call from the driver trying to set the dither depth...
if (usDitherDepth > MIXVAL_DITHERDEPTH_COUNT)
{
m_usDitherDepth = usDitherDepth; // remember for later...
usDitherDepth = m_usDitherControl; // reset usDitherDepth so the code below will work
}
m_usDitherControl = usDitherDepth; // save value for GetDitherDepth
switch (m_usDitherControl)
{
case MIXVAL_DITHERDEPTH_AUTO:
// The user wants the driver to select the dither depth.
// Next time this device gets started the dither depth will get set.
break;
case MIXVAL_DITHERDEPTH_8BIT:
m_usDitherDepth = 8;
break;
case MIXVAL_DITHERDEPTH_16BIT:
m_usDitherDepth = 16;
break;
case MIXVAL_DITHERDEPTH_20BIT:
m_usDitherDepth = 20;
break;
case MIXVAL_DITHERDEPTH_24BIT: // Dither is off
m_usDitherDepth = 24;
break;
}
ULONG ulDitherDepth;
switch (m_usDitherDepth)
{
case 8:
ulDitherDepth = REG_RMIX_DITHERDEPTH_8BITS;
break;
case 16:
ulDitherDepth = REG_RMIX_DITHERDEPTH_16BITS;
break;
case 20:
ulDitherDepth = REG_RMIX_DITHERDEPTH_20BITS;
break;
default:
case 24:
ulDitherDepth = REG_RMIX_DITHERDEPTH_24BITS;
m_usDitherDepth = 24;
break;
}
//cmn_err((CE_WARN,"ulDitherDepth %08lx\n", ulDitherDepth ));
m_RegMixControl.Write (ulDitherDepth, REG_RMIX_DITHERDEPTH_MASK);
SetDither (m_bDither); // update the dither on/off status
}
/////////////////////////////////////////////////////////////////////////////
void
CHalRecordMix::SetDither (BOOLEAN bDither)
/////////////////////////////////////////////////////////////////////////////
{
m_bDither = bDither ? TRUE : FALSE;
// if the dither depth is 24, turn off dither in the hardware
if (m_usDitherDepth == 24)
m_RegMixControl.BitSet (REG_RMIX_DITHER, FALSE);
else
{
//cmn_err((CE_WARN,"REG_RMIX_DITHER %08lx\n", m_bDither ));
m_RegMixControl.BitSet (REG_RMIX_DITHER, m_bDither);
}
}
// PLEASE NOTE: See CHalAdapter::SetDitherType( PHALREGISTER pRMix0Control, USHORT usDitherType ) to set the DitherType
|