📄 wmdrivermessage.c
字号:
/* Ensure that the supplied parameters are valid */
if ( ! WM_SIGNAL_IS_RECORDABLE( leftInput ) )
{
WM_TRACE( hDevice, (
"WMDriverMessage - invalid clear record selection (left) %d",
leftInput)
);
status = WMS_INVALID_PARAMETER;
break;
}
if ( ! WM_SIGNAL_IS_RECORDABLE( rightInput ) )
{
WM_TRACE( hDevice, (
"WMDriverMessage - invalid clear record selection (right) %d",
rightInput)
);
status = WMS_INVALID_PARAMETER;
break;
}
/* And change our settings */
WM_TRACE( hDevice, (
"WMDriverMessage unsetting record paths to L = %d, R = %d",
leftInput,
rightInput
));
status = WMAudioClearRecPaths( hDevice, leftInput, rightInput );
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice, (
"WMDriverMessage: clear record paths failed: %s",
WMStatusText( status )
));
break;
}
break;
}
#endif /* WM_AUDIO */
/* Read the ID of a codec */
case WMMSG_READ_DEVICE_ID:
{
WM_CHIPTYPE *pChipType = (WM_REGVAL *) dwParam1;
WM_CHIPREV *pRevision = (WM_REGVAL *) dwParam2;
status = WMGetDeviceType( hDevice, pChipType, pRevision );
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice, (
"WMDriverMessage: read ID failed: %s",
WMStatusText( status )
));
break;
}
WM_TRACE( hDevice, (
"WMDriverMessage read ID: WM%04X, Rev:= 0x%04X",
*pChipType,
*pRevision
));
break;
}
/* Write to a codec register */
case WMMSG_WRITE_WMREGISTER:
{
reg = (WM_REGTYPE) dwParam1;
value = (WM_REGVAL) dwParam2;
status = WMWrite( hDevice, reg, value );
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice, (
"WMDriverMessage: write failed: %s",
WMStatusText( status )
));
break;
}
WM_TRACE( hDevice, (
"WMDriverMessage write: R0x%02X := 0x%04X",
reg,
value
));
break;
}
/* Raw write to a codec register */
case WMMSG_RAW_WRITE_WMREGISTER:
{
reg = (WM_REGTYPE) dwParam1;
value = (WM_REGVAL) dwParam2;
status = WMWrite( hDevice, reg, value );
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice, (
"WMDriverMessage: RAW write failed: %s",
WMStatusText( status )
));
break;
}
WM_TRACE( hDevice, (
"WMDriverMessage RAW write: R0x%02X := 0x%04X",
reg,
value
));
break;
}
/* Read from a codec register */
case WMMSG_READ_WMREGISTER:
{
WM_REGVAL *pValue = (WM_REGVAL *) dwParam2;
reg = (WM_REGTYPE) dwParam1;
if ( !pValue )
{
WM_TRACE( hDevice, (
"WMDriverMessage read: no buffer supplied"
));
status = WMS_INVALID_PARAMETER;
break;
}
status = WMRead( hDevice, reg, &value );
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice, (
"WMDriverMessage: read failed: %s",
WMStatusText( status )
));
break;
}
WM_TRACE( hDevice, (
"WMDriverMessage read R%02Xh := 0x%04X ",
reg,
value
));
*pValue = value;
break;
}
/* Raw read from a codec register */
case WMMSG_RAW_READ_WMREGISTER:
{
WM_REGVAL *pValue = (WM_REGVAL *) dwParam2;
reg = (WM_REGTYPE) dwParam1;
if ( !pValue )
{
WM_TRACE( hDevice, (
"WMDriverMessage read: no buffer supplied"
));
status = WMS_INVALID_PARAMETER;
break;
}
status = WMRead( hDevice, reg, &value );
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice, (
"WMDriverMessage: read failed: %s",
WMStatusText( status )
));
break;
}
WM_TRACE( hDevice, (
"WMDriverMessage RAW read %x %x ",
reg,
value
));
*pValue = value;
break;
}
/* Load a named profile */
case WMMSG_LOAD_PROFILE:
{
const char *profile = (const char *) dwParam1;
if ( !profile )
{
WM_TRACE( hDevice, (
"WMDriverMessage load profile: no name supplied"
));
status = WMS_INVALID_PARAMETER;
break;
}
status = WMLoadNamedProfile( hDevice, profile );
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice, (
"WMDriverMessage: load profile '%s' failed: %s",
profile,
WMStatusText( status )
));
break;
}
WM_TRACE( hDevice, (
"WMDriverMessage loaded profile '%s'",
profile
));
break;
}
/* Assorted test functions */
case WMMSG_DIAG_MSG:
{
switch (dwParam1)
{
case WMMSG_DIAG_RESET: // cold reset of the codec
WM_TRACE( hDevice, ( "WMDriverMessage resetting device (cold reset)" ) );
status = WMReset( hDevice );
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice, (
"WMDriverMessage: reset failed: %s",
WMStatusText( status )
));
}
break;
case WMMSG_DIAG_WAKE: // warm reset of the codec
WM_TRACE( hDevice, ( "WMDriverMessage waking device (warm reset)" ) );
status = WMWake( hDevice );
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice, (
"WMDriverMessage: wake failed: %s",
WMStatusText( status )
));
}
break;
default:
status = WMS_UNSUPPORTED;
break;
}
break;
}
/* Power up and power down */
case WMMSG_POWERUP_MSG:
case WMMSG_POWERDOWN_MSG:
{
WM_DRIVER_ID driver = (WM_DRIVER_ID) dwParam1;
WM_POWERFLAG powerSections = (WM_POWERFLAG) dwParam2;
if ( WMMSG_POWERUP_MSG == uMsg )
status = WMPowerUp( hDevice, driver, powerSections );
else
status = WMPowerDown( hDevice, driver, powerSections );
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice, (
"WMDriverMessage: power %s failed: %s",
( WMMSG_POWERUP_MSG == uMsg ) ? "up" : "down",
WMStatusText( status )
));
}
break;
}
default:
{
WM_TRACE( hDevice, (
"WMDriverMessage Unknown Message [%x] ",
uMsg
));
status = WMS_UNSUPPORTED;
}
}
return status;
}
/*------------------------------ END OF FILE ---------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -