1/*
2* Copyright 2003-2006, Haiku.
3* Distributed under the terms of the MIT License.
4*
5* A module driver for the generic mpu401 midi interface.
6*
7* Author:
8*		Greg Crain (gsc70@comcast.net)
9*
10* mpu401_priv.h
11*/
12
13#ifndef mpu401_priv_H
14#define mpu401_priv_H
15
16#include <module.h>
17#include <PCI.h>
18
19/*--------------------------------*/
20/* UART Definitions               */
21
22#define MPU401_RESET    0xff
23#define MPU401_UART     0x3f
24#define MPU401_CMDOK    0xfe
25#define MPU401_OK2WR    0x40
26#define MPU401_OK2RD    0x80
27// Typically,
28//  UART data port = addr
29//  UART cmd port = addr +1
30#define UARTDATA		0
31#define UARTCMD			1
32
33#define MBUF_ELEMENTS    1000  //Input buffer size
34
35/*--------------------------------*/
36/* Private definitions            */
37
38typedef struct _mpu401device {
39	unsigned int addrport;
40	unsigned int  workarounds;
41	int32 count;
42	bool V2;
43	sem_id readsemaphore;
44	sem_id writesemaphore;
45	void (*interrupt_op)(int32 op, void * card);
46	void *card;
47} mpu401device;
48
49int mbuf_current;
50int mbuf_start;
51int mbuf_bytes;
52unsigned char mpubuffer[MBUF_ELEMENTS];
53static int open_count;
54static isa_module_info *gISA;
55static pci_module_info *gPCI;
56
57
58/*--------------------------------*/
59/* Function prototypes            */
60
61unsigned char Read_MPU401(unsigned int, const char, unsigned int);
62status_t Write_MPU401(unsigned int, const char, unsigned int, uchar);
63
64cpu_status lock(void);
65void unlock (cpu_status);
66
67/********************/
68/*   Workarounds    */
69/********************/
70// This is a list of workarounds in order to
71// get a specific manufacturer, card vendor, or UART type
72// to work nicely with the generic module.
73// The defined workaround value must match the value that
74// is used in the driver 'create_device' call.
75
76
77/****************************/
78/* Creative Audigy, Audigy2 */
79/****************************/
80/* 0x11020004   Gameport Midi connector       */
81/* 0x11020005   LiveDrive Expansion connector */
82/* IN the create_device hook, use the PCI base*/
83/* address, instead of midi address port      */
84#define PTR_ADDRESS_MASK 0x0fff0000
85#define D_DATA 0x04
86#define D_PTR  0x00
87#define I_MPU1 0x70
88#define I_MPU2 0x72
89
90
91#endif // mpu401_priv_H
92
93