summaryrefslogtreecommitdiff
path: root/setup/Linux/oss/cuckoo/cuckoo.h
blob: 3df29668f5775dd643f66ae5a8277bb8f7b19457 (plain)
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
/*
 * This software module makes it possible to use Open Ssund System for Linux
 * (the _professional_ version) as a low level driver source for ALSA.
 *
 * Copyright (C) 2004-2006 Hannu Savolainen (hannu@voimakentta.net).
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */

#define _KERNEL

/*
 * !!!!!!!!!!!!!!!!!!!! Important  !!!!!!!!!!!!!!!!!!
 *
 * If this file doesn't compile, you must not try to resolve the problem
 * without perfect understanding of internals of Linux kernel, ALSA and
 * Open Sound System.
 *
 * Instead you need to check that you are using the version of this file
 * that matches the versions of ALSA, OSS and Linux you are currently using.
 */

#define _KERNEL
#include "../include/sys/soundcard.h"

#include <linux/version.h>

#define _LOOSE_KERNEL_NAMES

#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
#include <linux/config.h>
#else
#include <linux/autoconf.h>
#endif

#if !defined(__SMP__) && defined(CONFIG_SMP)
#define __SMP__
#endif
#include <linux/module.h>

#include <stdarg.h>

extern int oss_get_cardinfo (int cardnum, oss_card_info * ci);	/* from oss_config.h */

#include <linux/param.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/signal.h>
#include <linux/fcntl.h>
#include <linux/sched.h>
#include <linux/timer.h>
#include <linux/tty.h>
#include <linux/mm.h>
#include <linux/ctype.h>
#include <linux/delay.h>
#include <linux/vmalloc.h>
#include <asm/processor.h>
#include <asm/io.h>
#include <linux/pci.h>
#include <linux/apm_bios.h>
#include <asm/segment.h>
#include <asm/uaccess.h>
#include <linux/poll.h>

#include <asm/system.h>
#include <asm/dma.h>
#include <linux/wait.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/ioport.h>
//#include <asm/mach-default/irq_vectors.h>
#include <linux/interrupt.h>
#include <linux/pm.h>

struct _oss_mutex_t
{
  /* Caution! This definition must match Linux/osscore.c */
  spinlock_t lock;
};

#define audio_devs dummy_audio_devs

#include "../include/internals/oss_exports.h"
#include "../build/wrap.h"
#include "../include/internals/ossddk.h"

typedef struct oss_wait_queue oss_wait_queue_t;	/* This must match oss_config.h */

#include "../include/internals/ossddk.h"

//#include <sound/driver.h>
#include <sound/core.h>
#include <sound/control.h>
#include <sound/pcm.h>

#include "../build/osscore_symbols.inc"

#define SNDRV_GET_ID
#include <sound/initval.h>

typedef caddr_t ioctl_arg;
typedef char snd_rw_buf;

typedef int sound_os_info;

#define WR_BUF_CONST	const

#include "../include/internals/audio_core.h"
#include "../include/internals/mixer_core.h"

typedef struct _snd_cuckoo cuckoo_t, chip_t;

typedef struct
{
  adev_p adev;
} cuckoo_pcm_t;

#define MAX_OSSPCM 24		// Max # of PCM devices/card instance

#if 1
// Older ALSA versions used to define these...
typedef struct snd_card snd_card_t;
typedef struct snd_pcm snd_pcm_t;
typedef struct snd_rawmidi snd_rawmidi_t;
typedef struct snd_rawmidi_substream snd_rawmidi_substream_t;
typedef struct snd_rawmidi_ops snd_rawmidi_ops_t;
typedef struct snd_kcontrol snd_kcontrol_t;
typedef struct snd_kcontrol_new snd_kcontrol_new_t;
typedef struct snd_ctl_elem_info snd_ctl_elem_info_t;
typedef struct snd_ctl_elem_value snd_ctl_elem_value_t;
typedef struct snd_pcm_substream snd_pcm_substream_t;
typedef struct snd_pcm_hardware snd_pcm_hardware_t;
typedef struct snd_pcm_runtime snd_pcm_runtime_t;
typedef struct snd_pcm_hw_params snd_pcm_hw_params_t;
typedef struct snd_pcm_ops snd_pcm_ops_t;
typedef struct snd_device snd_device_t;
typedef struct snd_device_ops snd_device_ops_t;
#endif

struct _snd_cuckoo
{
  snd_card_t *card;
  snd_pcm_t *pcm[MAX_OSSPCM];
  adev_p play_adev[MAX_OSSPCM], capture_adev[MAX_OSSPCM];
  int osscard;
  int nplay, ncapture, npcm;
};

#define cuckoo_t_magic 0xaabbccdd
#define chip__tmagic cuckoo_t_magic

//#define OPEN_READ	PCM_ENABLE_INPUT
//#define OPEN_WRITE	PCM_ENABLE_OUTPUT

extern int install_mixer_instances (cuckoo_t * chip, int cardno);
extern int install_midiport_instances (cuckoo_t * chip, int cardno);
extern int install_pcm_instances (cuckoo_t * chip, int cardno);

// Disable locking for now
#define udi_spin_lock_irqsave(a, b) *(b)=0
#define udi_spin_unlock_irqrestore(a, b)

#define strlcpy(a, b) {strncpy(a, b, sizeof(a)-1);a[sizeof(a)-1]=0;}