diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2011-09-13 05:24:41 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-09-14 05:00:51 -0400 |
commit | dba8b46992c55946d3b092934f581a343403118f (patch) | |
tree | 7ea5af971bc5cc8ecf4c8af1e0547fa11291ba86 /Documentation | |
parent | 47124373b59e43fd07cbf7b44d9288f19c1d5a93 (diff) |
ALSA: mpu401: clean up interrupt specification
The semantics of snd_mpu401_uart_new()'s interrupt parameters are
somewhat counterintuitive: To prevent the function from allocating its
own interrupt, either the irq number must be invalid, or the irq_flags
parameter must be zero. At the same time, the irq parameter being
invalid specifies that the mpu401 code has to work without an interrupt
allocated by the caller. This implies that, if there is an interrupt
and it is allocated by the caller, the irq parameter must be set to
a valid-looking number which then isn't actually used.
With the removal of IRQF_DISABLED, zero becomes a valid irq_flags value,
which forces us to handle the parameters differently.
This patch introduces a new flag MPU401_INFO_IRQ_HOOK for when the
device interrupt is handled by the caller, and makes the allocation of
the interrupt to depend only on the irq parameter. As suggested by
Takashi, the irq_flags parameter was dropped because, when used, it had
the constant value IRQF_DISABLED.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/DocBook/writing-an-alsa-driver.tmpl | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/Documentation/DocBook/writing-an-alsa-driver.tmpl b/Documentation/DocBook/writing-an-alsa-driver.tmpl index 598c22f3b3ac..5de23c007078 100644 --- a/Documentation/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/DocBook/writing-an-alsa-driver.tmpl | |||
@@ -4288,7 +4288,7 @@ struct _snd_pcm_runtime { | |||
4288 | <![CDATA[ | 4288 | <![CDATA[ |
4289 | struct snd_rawmidi *rmidi; | 4289 | struct snd_rawmidi *rmidi; |
4290 | snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, port, info_flags, | 4290 | snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, port, info_flags, |
4291 | irq, irq_flags, &rmidi); | 4291 | irq, &rmidi); |
4292 | ]]> | 4292 | ]]> |
4293 | </programlisting> | 4293 | </programlisting> |
4294 | </informalexample> | 4294 | </informalexample> |
@@ -4343,6 +4343,13 @@ struct _snd_pcm_runtime { | |||
4343 | by itself to start processing the output stream in the irq handler. | 4343 | by itself to start processing the output stream in the irq handler. |
4344 | </para> | 4344 | </para> |
4345 | 4345 | ||
4346 | <para> | ||
4347 | If the MPU-401 interface shares its interrupt with the other logical | ||
4348 | devices on the card, set <constant>MPU401_INFO_IRQ_HOOK</constant> | ||
4349 | (see <link linkend="midi-interface-interrupt-handler"><citetitle> | ||
4350 | below</citetitle></link>). | ||
4351 | </para> | ||
4352 | |||
4346 | <para> | 4353 | <para> |
4347 | Usually, the port address corresponds to the command port and | 4354 | Usually, the port address corresponds to the command port and |
4348 | port + 1 corresponds to the data port. If not, you may change | 4355 | port + 1 corresponds to the data port. If not, you may change |
@@ -4375,14 +4382,12 @@ struct _snd_pcm_runtime { | |||
4375 | </para> | 4382 | </para> |
4376 | 4383 | ||
4377 | <para> | 4384 | <para> |
4378 | The 6th argument specifies the irq number for UART. If the irq | 4385 | The 6th argument specifies the ISA irq number that will be |
4379 | is already allocated, pass 0 to the 7th argument | 4386 | allocated. If no interrupt is to be allocated (because your |
4380 | (<parameter>irq_flags</parameter>). Otherwise, pass the flags | 4387 | code is already allocating a shared interrupt, or because the |
4381 | for irq allocation | 4388 | device does not use interrupts), pass -1 instead. |
4382 | (<constant>SA_XXX</constant> bits) to it, and the irq will be | 4389 | For a MPU-401 device without an interrupt, a polling timer |
4383 | reserved by the mpu401-uart layer. If the card doesn't generate | 4390 | will be used instead. |
4384 | UART interrupts, pass -1 as the irq number. Then a timer | ||
4385 | interrupt will be invoked for polling. | ||
4386 | </para> | 4391 | </para> |
4387 | </section> | 4392 | </section> |
4388 | 4393 | ||
@@ -4390,12 +4395,13 @@ struct _snd_pcm_runtime { | |||
4390 | <title>Interrupt Handler</title> | 4395 | <title>Interrupt Handler</title> |
4391 | <para> | 4396 | <para> |
4392 | When the interrupt is allocated in | 4397 | When the interrupt is allocated in |
4393 | <function>snd_mpu401_uart_new()</function>, the private | 4398 | <function>snd_mpu401_uart_new()</function>, an exclusive ISA |
4394 | interrupt handler is used, hence you don't have anything else to do | 4399 | interrupt handler is automatically used, hence you don't have |
4395 | than creating the mpu401 stuff. Otherwise, you have to call | 4400 | anything else to do than creating the mpu401 stuff. Otherwise, you |
4396 | <function>snd_mpu401_uart_interrupt()</function> explicitly when | 4401 | have to set <constant>MPU401_INFO_IRQ_HOOK</constant>, and call |
4397 | a UART interrupt is invoked and checked in your own interrupt | 4402 | <function>snd_mpu401_uart_interrupt()</function> explicitly from your |
4398 | handler. | 4403 | own interrupt handler when it has determined that a UART interrupt |
4404 | has occurred. | ||
4399 | </para> | 4405 | </para> |
4400 | 4406 | ||
4401 | <para> | 4407 | <para> |