ReactOS  0.4.15-dev-1184-g23e04ae
common.cpp File Reference
#include "common.hpp"
Include dependency graph for common.cpp:

Go to the source code of this file.

Functions

NTSTATUS NewCMIAdapter (PUNKNOWN *Unknown, REFCLSID, PUNKNOWN UnknownOuter, POOL_TYPE PoolType)
 
 STDMETHODIMP_ (NTSTATUS) CCMIAdapter
 
 STDMETHODIMP_ (void) CCMIAdapter
 
 STDMETHODIMP_ (UInt8) CCMIAdapter
 
 STDMETHODIMP_ (UInt16) CCMIAdapter
 
 STDMETHODIMP_ (UInt32) CCMIAdapter
 

Function Documentation

◆ NewCMIAdapter()

NTSTATUS NewCMIAdapter ( PUNKNOWN Unknown,
REFCLSID  ,
PUNKNOWN  UnknownOuter,
POOL_TYPE  PoolType 
)

Definition at line 34 of file common.cpp.

35 {
36  PAGED_CODE();
37  DBGPRINT(("NewCMIAdapter()"));
38  ASSERT (Unknown);
39  STD_CREATE_BODY_(CCMIAdapter, Unknown, UnknownOuter, PoolType, PCMIADAPTER);
40 }
#define DBGPRINT(...)
Definition: pdo.c:21
ICMIAdapter * PCMIADAPTER
Definition: interfaces.hpp:260
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T _In_ POOL_TYPE PoolType
Definition: fltkernel.h:1444
#define PAGED_CODE()

◆ STDMETHODIMP_() [1/5]

STDMETHODIMP_ ( NTSTATUS  )

Definition at line 43 of file common.cpp.

44 {
45  PAGED_CODE();
47  ASSERT(aDeviceObject);
48  ASSERT(ResourceList->FindTranslatedPort(0));
49  DBGPRINT(("CCMIAdapter[%p]::init()", this));
50 
51  NTSTATUS ntStatus = STATUS_SUCCESS;
52 
53  RtlFillMemory(&mixerCache, 0xFF, 0xFF);
54  RtlFillMemory(&cm, sizeof(cm), 0x00);
55 
56  DeviceObject = aDeviceObject;
57 
58  cm.IOBase = 0;
59  for (unsigned int i=0;i<ResourceList->NumberOfPorts();i++) {
60  if (ResourceList->FindTranslatedPort(i)->u.Port.Length == 0x100) {
61  cm.IOBase = (UInt32*)ResourceList->FindTranslatedPort(i)->u.Port.Start.QuadPart;
62  }
63  }
64 
65  if (cm.IOBase == 0) {
67  }
68  cm.MPUBase = 0;
69 
70 #ifdef WAVERT
71  INFOPRINT(("Driver Version: %s-WAVERT", CMIVERSION));
72 #else
73  INFOPRINT(("Driver Version: %s", CMIVERSION));
74 #endif
75  INFOPRINT(("Configuration:"));
76  INFOPRINT((" IO Base: 0x%X", cm.IOBase));
77  INFOPRINT((" MPU Base: 0x%X", cm.MPUBase));
78 
79  if (!queryChip()) {
81  }
82 
83  INFOPRINT((" Chip Version: %d", cm.chipVersion));
84  INFOPRINT((" Max Channels: %d", cm.maxChannels));
85  INFOPRINT((" CanAC3HW: %d", cm.canAC3HW));
86 
87  resetController();
88 
89  ntStatus = PcNewInterruptSync(&(InterruptSync), NULL, ResourceList, 0, InterruptSyncModeNormal);
90  if (!NT_SUCCESS(ntStatus) || !(InterruptSync)) {
91  DBGPRINT(("Failed to create an interrupt sync!"));
93  }
94  ntStatus = InterruptSync->RegisterServiceRoutine(InterruptServiceRoutine, (PVOID)this, FALSE);
95  if (!NT_SUCCESS(ntStatus)) {
96  DBGPRINT(("Failed to register ISR!"));
97  return ntStatus;
98  }
99 
100  ntStatus = InterruptSync->Connect();
101  if (!NT_SUCCESS(ntStatus)) {
102  DBGPRINT(("Failed to connect the ISR with InterruptSync!"));
103  return ntStatus;
104  }
105 
106  // Initialize the device state.
107  CurrentPowerState = PowerDeviceD0;
108 
109  return ntStatus;
110 }
#define DBGPRINT(...)
Definition: pdo.c:21
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
DWORD UInt32
Definition: chm_lib.c:104
LONG NTSTATUS
Definition: precomp.h:26
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593
NTSTATUS NTAPI PcNewInterruptSync(OUT PINTERRUPTSYNC *OutInterruptSync, IN PUNKNOWN OuterUnknown OPTIONAL, IN PRESOURCELIST ResourceList, IN ULONG ResourceIndex, IN INTERRUPTSYNCMODE Mode)
Definition: interrupt.cpp:323
#define INFOPRINT(msg)
Definition: debug.hpp:47
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define CMIVERSION
Definition: debug.hpp:31
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define PAGED_CODE()

◆ STDMETHODIMP_() [2/5]

STDMETHODIMP_ ( void  )

Definition at line 287 of file common.cpp.

288 {
289  PAGED_CODE();
290  DBGPRINT(("CCMIAdapter[%p]::PowerChangeState(%p)", this, NewState));
291 
292  if (NewState.DeviceState == CurrentPowerState ) {
293  return;
294  }
295 
296  switch (NewState.DeviceState) {
297  case PowerDeviceD0: // powering up, hardware access allowed
298  clearUInt32Bit(REG_MISCCTRL, PWD_CHIP);
299  cm.WaveMiniport->powerUp();
300  CurrentPowerState = NewState.DeviceState;
301  break;
302 
303  case PowerDeviceD1: // powering down, hardware access still allowed
304  setUInt32Bit(REG_MISCCTRL, PWD_CHIP);
305  CurrentPowerState = NewState.DeviceState;
306  break;
307 
308  case PowerDeviceD2: // sleep state - hardware access not allowed
309  case PowerDeviceD3: // hibernation state - hardware access not allowed
310  if (CurrentPowerState == PowerDeviceD0) {
311  cm.WaveMiniport->powerDown();
312  setUInt32Bit(REG_MISCCTRL, PWD_CHIP);
313  }
314  CurrentPowerState = NewState.DeviceState;
315  break;
316  default: // unknown power state
317  break;
318  }
319 }
#define DBGPRINT(...)
Definition: pdo.c:21
#define REG_MISCCTRL
Definition: cmireg.hpp:111
#define PAGED_CODE()
#define PWD_CHIP
Definition: cmireg.hpp:123

◆ STDMETHODIMP_() [3/5]

STDMETHODIMP_ ( UInt8  )

Definition at line 357 of file common.cpp.

358 {
359  return READ_PORT_UCHAR((PUCHAR)(reinterpret_cast<PUCHAR>(cm.IOBase) + reg));
360 }
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:21
unsigned char * PUCHAR
Definition: retypes.h:3
static int reg
Definition: i386-dis.c:1275

◆ STDMETHODIMP_() [4/5]

STDMETHODIMP_ ( UInt16  )

Definition at line 377 of file common.cpp.

378 {
379  return READ_PORT_USHORT((PUSHORT)(reinterpret_cast<PUCHAR>(cm.IOBase) + reg));
380 }
static int reg
Definition: i386-dis.c:1275
USHORT NTAPI READ_PORT_USHORT(IN PUSHORT Port)
Definition: portio.c:63
unsigned short * PUSHORT
Definition: retypes.h:2

◆ STDMETHODIMP_() [5/5]

STDMETHODIMP_ ( UInt32  )

Definition at line 388 of file common.cpp.

389 {
390  return READ_PORT_ULONG((PULONG)(reinterpret_cast<PUCHAR>(cm.IOBase) + reg));
391 }
ULONG NTAPI READ_PORT_ULONG(IN PULONG Port)
Definition: portio.c:70
unsigned int * PULONG
Definition: retypes.h:1
static int reg
Definition: i386-dis.c:1275