~ubuntu-branches/ubuntu/wily/oss4/wily

« back to all changes in this revision

Viewing changes to kernel/framework/midi/oss_default_timer.c

  • Committer: Bazaar Package Importer
  • Author(s): Romain Beauxis, Samuel Thibault, Romain Beauxis, Sebastien NOEL
  • Date: 2011-06-14 10:06:56 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110614100656-cx4oc7u426zn812z
Tags: 4.2-build2004-1
[ Samuel Thibault ]
* debian/control: Add liboss4-salsa2, liboss4-salsa-dev and
  liboss4-salsa-asound2 packages, equivalent to (and will replace) those from
  the oss-libsalsa package (Closes: #589127).
* debian/patches/liboss4-salsa.patch: New patch to rename libsalsa into
  liboss4-salsa to avoid conflicts in the archive for no good reason.
* debian/rules: Make in libOSSlib and libsalsa.
* debian/liboss4-salsa-dev.install, debian/liboss4-salsa2.install,
  debian/liboss4-salsa-asound2.links, debian/liboss4-salsa-dev.links:
  Install liboss4-salsa libraries like was done in the oss-libsalsa package.
* include-alsa: Add a copy of ALSA 1.0.5 headers: Cf ALSA_1.0.* symbols in
  libsalsa, this is the roughly supported version.
* debian/copyright: Update for new include-alsa files.
* alsa.pc: New file for compatibility with libasound-dev.
* debian/control:
  - Add Vcs-Browser and Vcs-Svn fields.
  - Use linux-any instead of the list of Linux archs (Closes: #604679).
  - Make dkms dependency linux-any only.
* debian/patches/hurd_iot.patch: New patch to fix soundcard.h usage in
  libsalsa on hurd-i386.
* debian/patches/libsalsa_fixes.patch: New patch to fix some printf usages
  and ioctl declaration in libsalsa.
* debian/patches/no_EBADE.patch: New patch to cope with hurd-i386 not having
  EBADE.
* debian/patches/CFLAGS.patch: New patch to make oss4 take debian/rules
  CFLAGS into account.
* debian/patches/snd_asoundlib_version.patch: New patch to add
  snd_asoundlib_version().
* debian/patches/generic_srccconf.patch: New patch to fix source
  configuration on unknown archs.

[ Romain Beauxis ]
* Fixed README.Debian to only mention dkms' modules.
* Switch to dpkg-source 3.0 (quilt) format
* Added DM-Upload-Allowed: yes

[ Sebastien NOEL ]
* New upstream release (Closes: #595298, #619272).
* Fix typo in initscript (Closes: #627149).
* debian/control: adjust linux-headers dependencies (Closes: #628879).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Purpose: Default MIDI timer (using system clock)
 
3
 */
 
4
/*
 
5
 *
 
6
 * This file is part of Open Sound System.
 
7
 *
 
8
 * Copyright (C) 4Front Technologies 1996-2008.
 
9
 *
 
10
 * This this source file is released under GPL v2 license (no other versions).
 
11
 * See the COPYING file included in the main directory of this source
 
12
 * distribution for the license terms and conditions.
 
13
 *
 
14
 */
 
15
 
 
16
#include "oss_config.h"
 
17
#include "midi_core.h"
 
18
 
 
19
typedef struct
 
20
{
 
21
  unsigned long long start_time;
 
22
  timeout_id_t timeout_id;
 
23
  oss_midi_wait_callback_t timer_callback;
 
24
  void *arg;
 
25
} deftmr_timerc_t;
 
26
 
 
27
static unsigned long long tick_scale = 1;
 
28
 
 
29
static int
 
30
deftmr_create_instance (int timer_dev, int driver_dev)
 
31
{
 
32
  deftmr_timerc_t *timerc;
 
33
 
 
34
  if ((timerc = KERNEL_MALLOC (sizeof (*timerc))) == NULL)
 
35
    return OSS_ENOMEM;
 
36
 
 
37
  memset (timerc, 0, sizeof (*timerc));
 
38
 
 
39
  oss_timer_devs[timer_dev]->timerc = timerc;
 
40
 
 
41
  return 0;
 
42
}
 
43
 
 
44
static void
 
45
deftmr_free_instance (int timer_dev, int driver_dev)
 
46
{
 
47
  deftmr_timerc_t *timerc;
 
48
 
 
49
  timerc = oss_timer_devs[timer_dev]->timerc;
 
50
  untimeout (timerc->timeout_id);
 
51
 
 
52
  if (timerc != NULL)
 
53
    KERNEL_FREE (timerc);
 
54
  oss_timer_devs[timer_dev]->timerc = NULL;
 
55
}
 
56
 
 
57
static int
 
58
deftmr_attach_client (int timer_dev, int mididev)
 
59
{
 
60
  return 0;
 
61
}
 
62
 
 
63
static void
 
64
deftmr_detach_client (int timer_dev, int mididev)
 
65
{
 
66
}
 
67
 
 
68
static int
 
69
deftmr_ioctl (int timer_dev, unsigned int cmd, ioctl_arg arg)
 
70
{
 
71
  return OSS_EINVAL;
 
72
}
 
73
 
 
74
static int
 
75
deftmr_set_source (int timer_dev, int source)
 
76
{
 
77
  return source;
 
78
}
 
79
 
 
80
static int
 
81
deftmr_set_tempo (int timer_dev, int tempo)
 
82
{
 
83
  return tempo;
 
84
}
 
85
 
 
86
static int
 
87
deftmr_set_timebase (int timer_dev, int timebase)
 
88
{
 
89
  return timebase;
 
90
}
 
91
static int
 
92
deftmr_start (int timer_dev, oss_uint64_t tick)
 
93
{
 
94
  deftmr_timerc_t *timerc;
 
95
 
 
96
  timerc = oss_timer_devs[timer_dev]->timerc;
 
97
 
 
98
  if (timerc == NULL)
 
99
    {
 
100
      cmn_err (CE_WARN, "deftmr_start: timerc==NULL\n");
 
101
      return OSS_EIO;
 
102
    }
 
103
 
 
104
  timerc->start_time = GET_JIFFIES ();
 
105
  return 0;
 
106
}
 
107
 
 
108
static int
 
109
deftmr_stop (int timer_dev)
 
110
{
 
111
  deftmr_timerc_t *timerc;
 
112
 
 
113
  timerc = oss_timer_devs[timer_dev]->timerc;
 
114
  untimeout (timerc->timeout_id);
 
115
 
 
116
  return 0;
 
117
}
 
118
 
 
119
static int
 
120
deftmr_cont (int timer_dev)
 
121
{
 
122
  return 0;
 
123
}
 
124
 
 
125
static int
 
126
deftmr_wait (int timer_dev, unsigned long long time,
 
127
             oss_midi_wait_callback_t callback, void *arg)
 
128
{
 
129
  deftmr_timerc_t *timerc;
 
130
  unsigned long long t;
 
131
 
 
132
  timerc = oss_timer_devs[timer_dev]->timerc;
 
133
  untimeout (timerc->timeout_id);
 
134
 
 
135
  t = ((oss_uint64_t) time + (tick_scale / 2)) / tick_scale;
 
136
 
 
137
  t += timerc->start_time;
 
138
 
 
139
  t -= GET_JIFFIES ();
 
140
 
 
141
  if (t < 0)
 
142
    {
 
143
      return 1;
 
144
    }
 
145
 
 
146
  timerc->timeout_id = timeout (callback, arg, t);
 
147
 
 
148
  return 0;
 
149
}
 
150
 
 
151
static unsigned long long
 
152
deftmr_get_current_time (int timer_dev)
 
153
{
 
154
  unsigned long long t;
 
155
  deftmr_timerc_t *timerc;
 
156
 
 
157
  timerc = oss_timer_devs[timer_dev]->timerc;
 
158
  /*
 
159
   * Compute time in system ticks since start of the timer
 
160
   */
 
161
  t = GET_JIFFIES ();
 
162
  if (t < timerc->start_time)
 
163
    return 0;
 
164
  t -= timerc->start_time;
 
165
 
 
166
  return t * tick_scale;        /* In microseconds */
 
167
}
 
168
 
 
169
oss_timer_driver_t default_midi_driver = {
 
170
  deftmr_create_instance,
 
171
  deftmr_free_instance,
 
172
  deftmr_attach_client,
 
173
  deftmr_detach_client,
 
174
  deftmr_ioctl,
 
175
  deftmr_wait,
 
176
  deftmr_get_current_time,
 
177
  deftmr_set_source,
 
178
  deftmr_set_tempo,
 
179
  deftmr_set_timebase,
 
180
  deftmr_start,
 
181
  deftmr_stop,
 
182
  deftmr_cont
 
183
};
 
184
 
 
185
void
 
186
attach_oss_default_timer (oss_device_t * osdev)
 
187
{
 
188
  int timer_dev;
 
189
 
 
190
  tick_scale = 1000000 / OSS_HZ;
 
191
  if ((timer_dev = oss_install_timer (OSS_TIMER_DRIVER_VERSION, "System timer", &default_midi_driver, sizeof (oss_timer_driver_t), 0,   /* Flags */
 
192
                                      16,       /* max_instances */
 
193
                                      1000000 / OSS_HZ, /* Resolution */
 
194
                                      NULL, osdev)) < 0)
 
195
    {
 
196
      cmn_err (CE_WARN, "Failed to install default MIDI timer\n");
 
197
      return;
 
198
    }
 
199
}
 
200
 
 
201
void
 
202
detach_oss_default_timer ()
 
203
{
 
204
}