ReactOS 0.4.15-dev-5666-gc548b97
mpu401.h
Go to the documentation of this file.
1/*
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: services/dd/mpu401/mpu401.h
6 * PURPOSE: MPU-401 MIDI device driver header
7 * PROGRAMMER: Andrew Greenwood
8 * UPDATE HISTORY:
9 * Sept 26, 2003: Created
10 */
11
12#pragma once
13
14//#include <mmsystem.h>
15//#include <mmddk.h>
16//#include <winioctl.h>
17#include "../../../dll/win32/mmdrv/mmdef.h"
18
19#define DEFAULT_PORT 0x330
20#define DEFAULT_IRQ 9
21
22#define DEVICE_SUBKEY L"Devices"
23#define PARMS_SUBKEY L"Parameters"
24
25#define REGISTRY_PORT L"Port"
26
27// At the moment, we just support a single device with fixed parameters:
28#define MPU401_PORT DEFAULT_PORT
29#define MPU401_IRQ DEFAULT_IRQ
30
31#define MPU401_TIMEOUT 10000
32
33/* OBSOLETE - see mmdef.h instead:
34#define IOCTL_SOUND_BASE FILE_DEVICE_SOUND
35// wave base 0
36#define IOCTL_MIDI_BASE 0x0080
37
38#define IOCTL_MIDI_GET_CAPABILITIES CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
39#define IOCTL_MIDI_SET_STATE CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0002, METHOD_BUFFERED, FILE_WRITE_ACCESS)
40#define IOCTL_MIDI_GET_STATE CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0003, METHOD_BUFFERED, FILE_WRITE_ACCESS)
41#define IOCTL_MIDI_SET_VOLUME CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS)
42#define IOCTL_MIDI_GET_VOLUME CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0005, METHOD_BUFFERED, FILE_READ_ACCESS)
43#define IOCTL_MIDI_PLAY CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0006, METHOD_BUFFERED, FILE_WRITE_ACCESS)
44#define IOCTL_MIDI_RECORD CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0007, METHOD_BUFFERED, FILE_WRITE_ACCESS)
45#define IOCTL_MIDI_CACHE_PATCHES CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0008, METHOD_BUFFERED, FILE_WRITE_ACCESS)
46#define IOCTL_MIDI_CACHE_DRUM_PATCHES CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0009, METHOD_BUFFERED, FILE_WRITE_ACCESS)
47*/
48
49// The MPU-401 has 2 ports, usually 0x330 and 0x331, which are known as
50// "data" and "status/command", respectively. These macros deal with
51// reading from and writing to these ports:
52
53#define MPU401_WRITE_DATA(bp, x) WRITE_PORT_UCHAR((PUCHAR) bp, x)
54#define MPU401_READ_DATA(bp) READ_PORT_UCHAR((PUCHAR) bp)
55#define MPU401_WRITE_COMMAND(bp, x) WRITE_PORT_UCHAR((PUCHAR) bp+1, x)
56#define MPU401_READ_STATUS(bp) READ_PORT_UCHAR((PUCHAR) bp+1)
57
58
59// Flow control
60
61#define MPU401_READY_TO_SEND(bp) \
62 MPU401_READ_STATUS(bp) & 0x80
63
64#define MPU401_READY_TO_RECEIVE(bp) \
65 MPU401_READ_STATUS(bp) & 0x40
66
67
68#define MPU401_WRITE_BYTE(bp, x) \
69 if (WaitToSend(bp)) MPU401_WRITE_DATA(bp, x)
70
71#define MPU401_WRITE_MESSAGE(bp, status, da, db) \
72 MPU401_WRITE(bp, status); \
73 MPU401_WRITE(bp, da); \
74 MPU401_WRITE(bp, db)
75
76//#define MPU401_READ(bp)
77// if (WaitToRead(bp)) ... ???
78
79/*
80 DEVICE_EXTENSION contains the settings for each individual device
81*/
82
83typedef struct _DEVICE_EXTENSION
84{
89// KDPC Dpc;
90// KTIMER Timer;
91// KEVENT Event;
92// BOOLEAN BeepOn;
94
95/*
96 DEVICE_INSTANCE contains ???
97*/
98
99typedef struct _DEVICE_INSTANCE
100{
101 // pPrevGDI
104
105/*
106 CONFIG contains device parameters (port/IRQ)
107 THIS STRUCTURE IS REDUNDANT
108*/
109
110//typedef struct _CONFIG
111//{
112// ULONG Port;
113// ULONG IRQ;
114//} CONFIG, *PCONFIG;
115
116/*
117 Some callback typedefs
118*/
119
122
123
124/*
125 Prototypes for functions in portio.c :
126*/
127
128BOOLEAN WaitToSend(ULONG BasePort);
129BOOLEAN WaitToReceive(ULONG BasePort);
130BOOLEAN InitUARTMode(ULONG BasePort);
131
132/*
133 Prototypes for functions in settings.c :
134*/
135
138 IN PWSTR SubKey,
141
149
unsigned char BOOLEAN
void LoadSettings(void)
Definition: settings.c:53
LONG NTSTATUS
Definition: precomp.h:26
DRIVER_INITIALIZE DriverEntry
Definition: condrv.c:21
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:312
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN WaitToReceive(ULONG BasePort)
Definition: portio.c:40
NTSTATUS NTAPI EnumDeviceKeys(IN PUNICODE_STRING RegistryPath, IN PWSTR SubKey, IN PREGISTRY_CALLBACK_ROUTINE Callback, IN PVOID Context)
Definition: settings.c:73
struct _DEVICE_EXTENSION DEVICE_EXTENSION
NTSTATUS REGISTRY_CALLBACK_ROUTINE(PWSTR RegistryPath, PVOID Context)
Definition: mpu401.h:120
BOOLEAN WaitToSend(ULONG BasePort)
Definition: portio.c:16
BOOLEAN InitUARTMode(ULONG BasePort)
Definition: portio.c:64
struct _DEVICE_EXTENSION * PDEVICE_EXTENSION
struct _DEVICE_INSTANCE * PDEVICE_INSTANCE
struct _DEVICE_INSTANCE DEVICE_INSTANCE
REGISTRY_CALLBACK_ROUTINE * PREGISTRY_CALLBACK_ROUTINE
Definition: mpu401.h:121
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
Definition: rtlfuncs.h:4196
PDRIVER_OBJECT DriverObject
Definition: mpu401.h:86
PUNICODE_STRING RegistryPath
Definition: mpu401.h:85
PDRIVER_OBJECT DriverObject
Definition: mpu401.h:102
uint16_t * PWSTR
Definition: typedefs.h:56
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG _Out_opt_ PULONG ValueType
Definition: wdfregistry.h:282
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
Definition: wdfregistry.h:275