^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * linux/sound/oss/dmasound/dmasound_paula.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Amiga `Paula' DMA Sound Driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * See linux/sound/oss/dmasound/dmasound_core.c for copyright and credits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * prior to 28/01/2001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * 28/01/2001 [0.1] Iain Sandoe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * - added versioning
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * - put in and populated the hardware_afmts field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * [0.2] - put in SNDCTL_DSP_GETCAPS value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * [0.3] - put in constraint on state buffer usage.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * [0.4] - put in default hard/soft settings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/ioport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/soundcard.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <asm/setup.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <asm/amigahw.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <asm/amigaints.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <asm/machdep.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include "dmasound.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define DMASOUND_PAULA_REVISION 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define DMASOUND_PAULA_EDITION 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define custom amiga_custom
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * The minimum period for audio depends on htotal (for OCS/ECS/AGA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * (Imported from arch/m68k/amiga/amisound.c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) extern volatile u_short amiga_audio_min_period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * amiga_mksound() should be able to restore the period after beeping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * (Imported from arch/m68k/amiga/amisound.c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) extern u_short amiga_audio_period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * Audio DMA masks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define AMI_AUDIO_OFF (DMAF_AUD0 | DMAF_AUD1 | DMAF_AUD2 | DMAF_AUD3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define AMI_AUDIO_8 (DMAF_SETCLR | DMAF_MASTER | DMAF_AUD0 | DMAF_AUD1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define AMI_AUDIO_14 (AMI_AUDIO_8 | DMAF_AUD2 | DMAF_AUD3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * Helper pointers for 16(14)-bit sound
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) static int write_sq_block_size_half, write_sq_block_size_quarter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /*** Low level stuff *********************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) static void *AmiAlloc(unsigned int size, gfp_t flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) static void AmiFree(void *obj, unsigned int size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) static int AmiIrqInit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #ifdef MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) static void AmiIrqCleanUp(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) static void AmiSilence(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) static void AmiInit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) static int AmiSetFormat(int format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) static int AmiSetVolume(int volume);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) static int AmiSetTreble(int treble);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static void AmiPlayNextFrame(int index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) static void AmiPlay(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) static irqreturn_t AmiInterrupt(int irq, void *dummy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #ifdef CONFIG_HEARTBEAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * Heartbeat interferes with sound since the 7 kHz low-pass filter and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * power LED are controlled by the same line.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) static void (*saved_heartbeat)(int) = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) static inline void disable_heartbeat(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) if (mach_heartbeat) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) saved_heartbeat = mach_heartbeat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) mach_heartbeat = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) AmiSetTreble(dmasound.treble);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static inline void enable_heartbeat(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) if (saved_heartbeat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) mach_heartbeat = saved_heartbeat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #else /* !CONFIG_HEARTBEAT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #define disable_heartbeat() do { } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #define enable_heartbeat() do { } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #endif /* !CONFIG_HEARTBEAT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) /*** Mid level stuff *********************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static void AmiMixerInit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static int AmiMixerIoctl(u_int cmd, u_long arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static int AmiWriteSqSetup(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static int AmiStateInfo(char *buffer, size_t space);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) /*** Translations ************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) /* ++TeSche: radically changed for new expanding purposes...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * These two routines now deal with copying/expanding/translating the samples
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * from user space into our buffer at the right frequency. They take care about
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * how much data there's actually to read, how much buffer space there is and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * to convert samples into the right frequency/encoding. They will only work on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * complete samples so it may happen they leave some bytes in the input stream
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * if the user didn't write a multiple of the current sample size. They both
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * return the number of bytes they've used from both streams so you may detect
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * such a situation. Luckily all programs should be able to cope with that.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * I think I've optimized anything as far as one can do in plain C, all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * variables should fit in registers and the loops are really short. There's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * one loop for every possible situation. Writing a more generalized and thus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * parameterized loop would only produce slower code. Feel free to optimize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * this in assembler if you like. :)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) * I think these routines belong here because they're not yet really hardware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * independent, especially the fact that the Falcon can play 16bit samples
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) * only in stereo is hardcoded in both of them!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * ++geert: split in even more functions (one per format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * Native format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) static ssize_t ami_ct_s8(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) u_char frame[], ssize_t *frameUsed, ssize_t frameLeft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) ssize_t count, used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) if (!dmasound.soft.stereo) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) void *p = &frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) count = min_t(unsigned long, userCount, frameLeft) & ~1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) used = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) if (copy_from_user(p, userPtr, count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) u_char *left = &frame[*frameUsed>>1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) u_char *right = left+write_sq_block_size_half;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) count = min_t(unsigned long, userCount, frameLeft)>>1 & ~1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) used = count*2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) while (count > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) if (get_user(*left++, userPtr++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) || get_user(*right++, userPtr++))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) *frameUsed += used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) return used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) * Copy and convert 8 bit data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) #define GENERATE_AMI_CT8(funcname, convsample) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) static ssize_t funcname(const u_char __user *userPtr, size_t userCount, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) u_char frame[], ssize_t *frameUsed, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) ssize_t frameLeft) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) ssize_t count, used; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) if (!dmasound.soft.stereo) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) u_char *p = &frame[*frameUsed]; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) count = min_t(size_t, userCount, frameLeft) & ~1; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) used = count; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) while (count > 0) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) u_char data; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) if (get_user(data, userPtr++)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) return -EFAULT; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) *p++ = convsample(data); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) count--; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) } else { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) u_char *left = &frame[*frameUsed>>1]; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) u_char *right = left+write_sq_block_size_half; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) count = min_t(size_t, userCount, frameLeft)>>1 & ~1; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) used = count*2; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) while (count > 0) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) u_char data; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (get_user(data, userPtr++)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) return -EFAULT; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) *left++ = convsample(data); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) if (get_user(data, userPtr++)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) return -EFAULT; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) *right++ = convsample(data); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) count--; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) *frameUsed += used; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) return used; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) #define AMI_CT_ULAW(x) (dmasound_ulaw2dma8[(x)])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) #define AMI_CT_ALAW(x) (dmasound_alaw2dma8[(x)])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) #define AMI_CT_U8(x) ((x) ^ 0x80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) GENERATE_AMI_CT8(ami_ct_ulaw, AMI_CT_ULAW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) GENERATE_AMI_CT8(ami_ct_alaw, AMI_CT_ALAW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) GENERATE_AMI_CT8(ami_ct_u8, AMI_CT_U8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) * Copy and convert 16 bit data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) #define GENERATE_AMI_CT_16(funcname, convsample) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) static ssize_t funcname(const u_char __user *userPtr, size_t userCount, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) u_char frame[], ssize_t *frameUsed, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) ssize_t frameLeft) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) const u_short __user *ptr = (const u_short __user *)userPtr; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) ssize_t count, used; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) u_short data; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) if (!dmasound.soft.stereo) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) u_char *high = &frame[*frameUsed>>1]; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) u_char *low = high+write_sq_block_size_half; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) count = min_t(size_t, userCount, frameLeft)>>1 & ~1; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) used = count*2; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) while (count > 0) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) if (get_user(data, ptr++)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) return -EFAULT; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) data = convsample(data); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) *high++ = data>>8; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) *low++ = (data>>2) & 0x3f; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) count--; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) } else { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) u_char *lefth = &frame[*frameUsed>>2]; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) u_char *leftl = lefth+write_sq_block_size_quarter; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) u_char *righth = lefth+write_sq_block_size_half; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) u_char *rightl = righth+write_sq_block_size_quarter; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) count = min_t(size_t, userCount, frameLeft)>>2 & ~1; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) used = count*4; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) while (count > 0) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) if (get_user(data, ptr++)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) return -EFAULT; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) data = convsample(data); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) *lefth++ = data>>8; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) *leftl++ = (data>>2) & 0x3f; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) if (get_user(data, ptr++)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) return -EFAULT; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) data = convsample(data); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) *righth++ = data>>8; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) *rightl++ = (data>>2) & 0x3f; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) count--; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) *frameUsed += used; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) return used; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) #define AMI_CT_S16BE(x) (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) #define AMI_CT_U16BE(x) ((x) ^ 0x8000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) #define AMI_CT_S16LE(x) (le2be16((x)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) #define AMI_CT_U16LE(x) (le2be16((x)) ^ 0x8000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) GENERATE_AMI_CT_16(ami_ct_s16be, AMI_CT_S16BE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) GENERATE_AMI_CT_16(ami_ct_u16be, AMI_CT_U16BE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) GENERATE_AMI_CT_16(ami_ct_s16le, AMI_CT_S16LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) GENERATE_AMI_CT_16(ami_ct_u16le, AMI_CT_U16LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) static TRANS transAmiga = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) .ct_ulaw = ami_ct_ulaw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) .ct_alaw = ami_ct_alaw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) .ct_s8 = ami_ct_s8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) .ct_u8 = ami_ct_u8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) .ct_s16be = ami_ct_s16be,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) .ct_u16be = ami_ct_u16be,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) .ct_s16le = ami_ct_s16le,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) .ct_u16le = ami_ct_u16le,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) /*** Low level stuff *********************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) static inline void StopDMA(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) custom.aud[0].audvol = custom.aud[1].audvol = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) custom.aud[2].audvol = custom.aud[3].audvol = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) custom.dmacon = AMI_AUDIO_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) enable_heartbeat();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) static void *AmiAlloc(unsigned int size, gfp_t flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) return amiga_chip_alloc((long)size, "dmasound [Paula]");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) static void AmiFree(void *obj, unsigned int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) amiga_chip_free (obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) static int __init AmiIrqInit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) /* turn off DMA for audio channels */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) StopDMA();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) /* Register interrupt handler. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) if (request_irq(IRQ_AMIGA_AUD0, AmiInterrupt, 0, "DMA sound",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) AmiInterrupt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) #ifdef MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) static void AmiIrqCleanUp(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) /* turn off DMA for audio channels */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) StopDMA();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) /* release the interrupt */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) free_irq(IRQ_AMIGA_AUD0, AmiInterrupt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) #endif /* MODULE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) static void AmiSilence(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) /* turn off DMA for audio channels */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) StopDMA();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) static void AmiInit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) int period, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) AmiSilence();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) if (dmasound.soft.speed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) period = amiga_colorclock/dmasound.soft.speed-1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) period = amiga_audio_min_period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) dmasound.hard = dmasound.soft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) dmasound.trans_write = &transAmiga;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) if (period < amiga_audio_min_period) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) /* we would need to squeeze the sound, but we won't do that */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) period = amiga_audio_min_period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) } else if (period > 65535) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) period = 65535;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) dmasound.hard.speed = amiga_colorclock/(period+1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) for (i = 0; i < 4; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) custom.aud[i].audper = period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) amiga_audio_period = period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) static int AmiSetFormat(int format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) int size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) /* Amiga sound DMA supports 8bit and 16bit (pseudo 14 bit) modes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) switch (format) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) case AFMT_QUERY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) return dmasound.soft.format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) case AFMT_MU_LAW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) case AFMT_A_LAW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) case AFMT_U8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) case AFMT_S8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) size = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) case AFMT_S16_BE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) case AFMT_U16_BE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) case AFMT_S16_LE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) case AFMT_U16_LE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) size = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) default: /* :-) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) size = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) format = AFMT_S8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) dmasound.soft.format = format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) dmasound.soft.size = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) if (dmasound.minDev == SND_DEV_DSP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) dmasound.dsp.format = format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) dmasound.dsp.size = dmasound.soft.size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) AmiInit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) return format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) #define VOLUME_VOXWARE_TO_AMI(v) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) (((v) < 0) ? 0 : ((v) > 100) ? 64 : ((v) * 64)/100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) #define VOLUME_AMI_TO_VOXWARE(v) ((v)*100/64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) static int AmiSetVolume(int volume)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) dmasound.volume_left = VOLUME_VOXWARE_TO_AMI(volume & 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) custom.aud[0].audvol = dmasound.volume_left;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) dmasound.volume_right = VOLUME_VOXWARE_TO_AMI((volume & 0xff00) >> 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) custom.aud[1].audvol = dmasound.volume_right;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) if (dmasound.hard.size == 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) if (dmasound.volume_left == 64 && dmasound.volume_right == 64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) custom.aud[2].audvol = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) custom.aud[3].audvol = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) custom.aud[2].audvol = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) custom.aud[3].audvol = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) return VOLUME_AMI_TO_VOXWARE(dmasound.volume_left) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) (VOLUME_AMI_TO_VOXWARE(dmasound.volume_right) << 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) static int AmiSetTreble(int treble)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) dmasound.treble = treble;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) if (treble < 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) ciaa.pra &= ~0x02;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) ciaa.pra |= 0x02;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) return treble;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) #define AMI_PLAY_LOADED 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) #define AMI_PLAY_PLAYING 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) #define AMI_PLAY_MASK 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) static void AmiPlayNextFrame(int index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) u_char *start, *ch0, *ch1, *ch2, *ch3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) u_long size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) /* used by AmiPlay() if all doubts whether there really is something
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) * to be played are already wiped out.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) start = write_sq.buffers[write_sq.front];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) size = (write_sq.count == index ? write_sq.rear_size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) : write_sq.block_size)>>1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) if (dmasound.hard.stereo) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) ch0 = start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) ch1 = start+write_sq_block_size_half;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) size >>= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) ch0 = start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) ch1 = start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) disable_heartbeat();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) custom.aud[0].audvol = dmasound.volume_left;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) custom.aud[1].audvol = dmasound.volume_right;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) if (dmasound.hard.size == 8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) custom.aud[0].audlc = (u_short *)ZTWO_PADDR(ch0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) custom.aud[0].audlen = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) custom.aud[1].audlc = (u_short *)ZTWO_PADDR(ch1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) custom.aud[1].audlen = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) custom.dmacon = AMI_AUDIO_8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) size >>= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) custom.aud[0].audlc = (u_short *)ZTWO_PADDR(ch0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) custom.aud[0].audlen = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) custom.aud[1].audlc = (u_short *)ZTWO_PADDR(ch1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) custom.aud[1].audlen = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) if (dmasound.volume_left == 64 && dmasound.volume_right == 64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) /* We can play pseudo 14-bit only with the maximum volume */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) ch3 = ch0+write_sq_block_size_quarter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) ch2 = ch1+write_sq_block_size_quarter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) custom.aud[2].audvol = 1; /* we are being affected by the beeps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) custom.aud[3].audvol = 1; /* restoring volume here helps a bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) custom.aud[2].audlc = (u_short *)ZTWO_PADDR(ch2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) custom.aud[2].audlen = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) custom.aud[3].audlc = (u_short *)ZTWO_PADDR(ch3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) custom.aud[3].audlen = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) custom.dmacon = AMI_AUDIO_14;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) custom.aud[2].audvol = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) custom.aud[3].audvol = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) custom.dmacon = AMI_AUDIO_8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) write_sq.front = (write_sq.front+1) % write_sq.max_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) write_sq.active |= AMI_PLAY_LOADED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) static void AmiPlay(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) int minframes = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) custom.intena = IF_AUD0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) if (write_sq.active & AMI_PLAY_LOADED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) /* There's already a frame loaded */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) custom.intena = IF_SETCLR | IF_AUD0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) if (write_sq.active & AMI_PLAY_PLAYING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) /* Increase threshold: frame 1 is already being played */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) minframes = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) if (write_sq.count < minframes) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) /* Nothing to do */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) custom.intena = IF_SETCLR | IF_AUD0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) if (write_sq.count <= minframes &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) write_sq.rear_size < write_sq.block_size && !write_sq.syncing) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) /* hmmm, the only existing frame is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) * yet filled and we're not syncing?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) custom.intena = IF_SETCLR | IF_AUD0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) AmiPlayNextFrame(minframes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) custom.intena = IF_SETCLR | IF_AUD0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) static irqreturn_t AmiInterrupt(int irq, void *dummy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) int minframes = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) custom.intena = IF_AUD0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) if (!write_sq.active) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) /* Playing was interrupted and sq_reset() has already cleared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) * the sq variables, so better don't do anything here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) WAKE_UP(write_sq.sync_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) if (write_sq.active & AMI_PLAY_PLAYING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) /* We've just finished a frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) write_sq.count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) WAKE_UP(write_sq.action_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) if (write_sq.active & AMI_PLAY_LOADED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) /* Increase threshold: frame 1 is already being played */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) minframes = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) /* Shift the flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) write_sq.active = (write_sq.active<<1) & AMI_PLAY_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) if (!write_sq.active)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) /* No frame is playing, disable audio DMA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) StopDMA();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) custom.intena = IF_SETCLR | IF_AUD0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) if (write_sq.count >= minframes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) /* Try to play the next frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) AmiPlay();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) if (!write_sq.active)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) /* Nothing to play anymore.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) Wake up a process waiting for audio output to drain. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) WAKE_UP(write_sq.sync_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) /*** Mid level stuff *********************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) * /dev/mixer abstraction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) static void __init AmiMixerInit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) dmasound.volume_left = 64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) dmasound.volume_right = 64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) custom.aud[0].audvol = dmasound.volume_left;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) custom.aud[3].audvol = 1; /* For pseudo 14bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) custom.aud[1].audvol = dmasound.volume_right;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) custom.aud[2].audvol = 1; /* For pseudo 14bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) dmasound.treble = 50;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) static int AmiMixerIoctl(u_int cmd, u_long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) int data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) case SOUND_MIXER_READ_DEVMASK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) return IOCTL_OUT(arg, SOUND_MASK_VOLUME | SOUND_MASK_TREBLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) case SOUND_MIXER_READ_RECMASK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) return IOCTL_OUT(arg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) case SOUND_MIXER_READ_STEREODEVS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) return IOCTL_OUT(arg, SOUND_MASK_VOLUME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) case SOUND_MIXER_READ_VOLUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) return IOCTL_OUT(arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) VOLUME_AMI_TO_VOXWARE(dmasound.volume_left) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) VOLUME_AMI_TO_VOXWARE(dmasound.volume_right) << 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) case SOUND_MIXER_WRITE_VOLUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) IOCTL_IN(arg, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) return IOCTL_OUT(arg, dmasound_set_volume(data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) case SOUND_MIXER_READ_TREBLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) return IOCTL_OUT(arg, dmasound.treble);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) case SOUND_MIXER_WRITE_TREBLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) IOCTL_IN(arg, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) return IOCTL_OUT(arg, dmasound_set_treble(data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) static int AmiWriteSqSetup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) write_sq_block_size_half = write_sq.block_size>>1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) write_sq_block_size_quarter = write_sq_block_size_half>>1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) static int AmiStateInfo(char *buffer, size_t space)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) len += sprintf(buffer+len, "\tsound.volume_left = %d [0...64]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) dmasound.volume_left);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) len += sprintf(buffer+len, "\tsound.volume_right = %d [0...64]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) dmasound.volume_right);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) if (len >= space) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) printk(KERN_ERR "dmasound_paula: overflowed state buffer alloc.\n") ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) len = space ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) /*** Machine definitions *****************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) static SETTINGS def_hard = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) .format = AFMT_S8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) .stereo = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) .size = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) .speed = 8000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) } ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) static SETTINGS def_soft = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) .format = AFMT_U8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) .stereo = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) .size = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) .speed = 8000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) } ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) static MACHINE machAmiga = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) .name = "Amiga",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) .name2 = "AMIGA",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) .dma_alloc = AmiAlloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) .dma_free = AmiFree,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) .irqinit = AmiIrqInit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) #ifdef MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) .irqcleanup = AmiIrqCleanUp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) #endif /* MODULE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) .init = AmiInit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) .silence = AmiSilence,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) .setFormat = AmiSetFormat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) .setVolume = AmiSetVolume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) .setTreble = AmiSetTreble,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) .play = AmiPlay,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) .mixer_init = AmiMixerInit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) .mixer_ioctl = AmiMixerIoctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) .write_sq_setup = AmiWriteSqSetup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) .state_info = AmiStateInfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) .min_dsp_speed = 8000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) .version = ((DMASOUND_PAULA_REVISION<<8) | DMASOUND_PAULA_EDITION),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) .hardware_afmts = (AFMT_S8 | AFMT_S16_BE), /* h'ware-supported formats *only* here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) .capabilities = DSP_CAP_BATCH /* As per SNDCTL_DSP_GETCAPS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) /*** Config & Setup **********************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) static int __init amiga_audio_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) dmasound.mach = machAmiga;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) dmasound.mach.default_hard = def_hard ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) dmasound.mach.default_soft = def_soft ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) return dmasound_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) static int __exit amiga_audio_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) dmasound_deinit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) static struct platform_driver amiga_audio_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) .remove = __exit_p(amiga_audio_remove),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) .name = "amiga-audio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) module_platform_driver_probe(amiga_audio_driver, amiga_audio_probe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) MODULE_ALIAS("platform:amiga-audio");