^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_atari.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Atari TT and Falcon 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) * 01/02/2001 [0.3] - put in default hard/soft settings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) */
^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) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/soundcard.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/spinlock.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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <asm/atariints.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <asm/atari_stram.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include "dmasound.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define DMASOUND_ATARI_REVISION 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define DMASOUND_ATARI_EDITION 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) extern void atari_microwire_cmd(int cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static int is_falcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static int write_sq_ignore_int; /* ++TeSche: used for Falcon */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static int expand_bal; /* Balance factor for expanding (not volume!) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static int expand_data; /* Data for expanding */
^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) /*** Translations ************************************************************/
^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) /* ++TeSche: radically changed for new expanding purposes...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * These two routines now deal with copying/expanding/translating the samples
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * from user space into our buffer at the right frequency. They take care about
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * how much data there's actually to read, how much buffer space there is and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * to convert samples into the right frequency/encoding. They will only work on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * complete samples so it may happen they leave some bytes in the input stream
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * if the user didn't write a multiple of the current sample size. They both
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * return the number of bytes they've used from both streams so you may detect
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * such a situation. Luckily all programs should be able to cope with that.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * 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 59) * variables should fit in registers and the loops are really short. There's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * one loop for every possible situation. Writing a more generalized and thus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * parameterized loop would only produce slower code. Feel free to optimize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * this in assembler if you like. :)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * I think these routines belong here because they're not yet really hardware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * independent, especially the fact that the Falcon can play 16bit samples
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * only in stereo is hardcoded in both of them!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * ++geert: split in even more functions (one per format)
^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) static ssize_t ata_ct_law(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) ssize_t frameLeft);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) static ssize_t ata_ct_s8(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) ssize_t frameLeft);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) static ssize_t ata_ct_u8(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) ssize_t frameLeft);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) static ssize_t ata_ct_s16be(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) ssize_t frameLeft);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) static ssize_t ata_ct_u16be(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) ssize_t frameLeft);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) static ssize_t ata_ct_s16le(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) ssize_t frameLeft);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) static ssize_t ata_ct_u16le(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) ssize_t frameLeft);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) static ssize_t ata_ctx_law(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) ssize_t frameLeft);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) static ssize_t ata_ctx_s8(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) ssize_t frameLeft);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) static ssize_t ata_ctx_u8(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) ssize_t frameLeft);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static ssize_t ata_ctx_s16be(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) ssize_t frameLeft);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) static ssize_t ata_ctx_u16be(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) ssize_t frameLeft);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static ssize_t ata_ctx_s16le(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) ssize_t frameLeft);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) static ssize_t ata_ctx_u16le(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) ssize_t frameLeft);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) /*** Low level stuff *********************************************************/
^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) static void *AtaAlloc(unsigned int size, gfp_t flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static void AtaFree(void *, unsigned int size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static int AtaIrqInit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #ifdef MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static void AtaIrqCleanUp(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #endif /* MODULE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) static int AtaSetBass(int bass);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static int AtaSetTreble(int treble);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static void TTSilence(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static void TTInit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) static int TTSetFormat(int format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static int TTSetVolume(int volume);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static int TTSetGain(int gain);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static void FalconSilence(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) static void FalconInit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static int FalconSetFormat(int format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) static int FalconSetVolume(int volume);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static void AtaPlayNextFrame(int index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) static void AtaPlay(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static irqreturn_t AtaInterrupt(int irq, void *dummy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /*** Mid level stuff *********************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) static void TTMixerInit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) static void FalconMixerInit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static int AtaMixerIoctl(u_int cmd, u_long arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static int TTMixerIoctl(u_int cmd, u_long arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static int FalconMixerIoctl(u_int cmd, u_long arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) static int AtaWriteSqSetup(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) static int AtaSqOpen(fmode_t mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) static int TTStateInfo(char *buffer, size_t space);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) static int FalconStateInfo(char *buffer, size_t space);
^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) /*** Translations ************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) static ssize_t ata_ct_law(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) ssize_t frameLeft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) char *table = dmasound.soft.format == AFMT_MU_LAW ? dmasound_ulaw2dma8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) : dmasound_alaw2dma8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) ssize_t count, used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) u_char *p = &frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) count = min_t(unsigned long, userCount, frameLeft);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) if (dmasound.soft.stereo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) count &= ~1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) used = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) while (count > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) u_char data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) if (get_user(data, userPtr++))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) *p++ = table[data];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) *frameUsed += used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) return used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) }
^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) static ssize_t ata_ct_s8(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) ssize_t frameLeft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) ssize_t count, used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) void *p = &frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) count = min_t(unsigned long, userCount, frameLeft);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) if (dmasound.soft.stereo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) count &= ~1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) used = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) if (copy_from_user(p, userPtr, count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) *frameUsed += used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) return used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) static ssize_t ata_ct_u8(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) ssize_t frameLeft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) ssize_t count, used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (!dmasound.soft.stereo) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) u_char *p = &frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) count = min_t(unsigned long, userCount, frameLeft);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) used = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) while (count > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) u_char data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (get_user(data, userPtr++))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) *p++ = data ^ 0x80;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) u_short *p = (u_short *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) count = min_t(unsigned long, userCount, frameLeft)>>1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) used = count*2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) while (count > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) u_short data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if (get_user(data, (u_short __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) userPtr += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) *p++ = data ^ 0x8080;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) *frameUsed += used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) return used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) static ssize_t ata_ct_s16be(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) ssize_t frameLeft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) ssize_t count, used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) if (!dmasound.soft.stereo) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) u_short *p = (u_short *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) count = min_t(unsigned long, userCount, frameLeft)>>1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) used = count*2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) while (count > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) u_short data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) if (get_user(data, (u_short __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) userPtr += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) *frameUsed += used*2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) void *p = (u_short *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) count = min_t(unsigned long, userCount, frameLeft) & ~3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) used = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) if (copy_from_user(p, userPtr, count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) *frameUsed += used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) return used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) static ssize_t ata_ct_u16be(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) ssize_t frameLeft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) ssize_t count, used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) if (!dmasound.soft.stereo) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) u_short *p = (u_short *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) count = min_t(unsigned long, userCount, frameLeft)>>1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) used = count*2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) while (count > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) u_short data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) if (get_user(data, (u_short __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) userPtr += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) data ^= 0x8000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) *frameUsed += used*2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) u_long *p = (u_long *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) count = min_t(unsigned long, userCount, frameLeft)>>2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) used = count*4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) while (count > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) u_int data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) if (get_user(data, (u_int __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) userPtr += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) *p++ = data ^ 0x80008000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) *frameUsed += used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) return used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) static ssize_t ata_ct_s16le(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) ssize_t frameLeft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) ssize_t count, used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) count = frameLeft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) if (!dmasound.soft.stereo) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) u_short *p = (u_short *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) count = min_t(unsigned long, userCount, frameLeft)>>1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) used = count*2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) while (count > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) u_short data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) if (get_user(data, (u_short __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) userPtr += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) data = le2be16(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) *frameUsed += used*2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) u_long *p = (u_long *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) count = min_t(unsigned long, userCount, frameLeft)>>2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) used = count*4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) while (count > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) u_long data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) if (get_user(data, (u_int __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) userPtr += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) data = le2be16dbl(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) *frameUsed += used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) return used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) static ssize_t ata_ct_u16le(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) ssize_t frameLeft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) ssize_t count, used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) count = frameLeft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) if (!dmasound.soft.stereo) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) u_short *p = (u_short *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) count = min_t(unsigned long, userCount, frameLeft)>>1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) used = count*2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) while (count > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) u_short data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) if (get_user(data, (u_short __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) userPtr += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) data = le2be16(data) ^ 0x8000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) *frameUsed += used*2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) u_long *p = (u_long *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) count = min_t(unsigned long, userCount, frameLeft)>>2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) used = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) while (count > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) u_long data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) if (get_user(data, (u_int __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) userPtr += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) data = le2be16dbl(data) ^ 0x80008000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) *frameUsed += used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) return used;
^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 ssize_t ata_ctx_law(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) ssize_t frameLeft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) char *table = dmasound.soft.format == AFMT_MU_LAW ? dmasound_ulaw2dma8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) : dmasound_alaw2dma8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) /* this should help gcc to stuff everything into registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) long bal = expand_bal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) long hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) ssize_t used, usedf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) used = userCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) usedf = frameLeft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) if (!dmasound.soft.stereo) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) u_char *p = &frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) u_char data = expand_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) while (frameLeft) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) u_char c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) if (bal < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) if (!userCount)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) if (get_user(c, userPtr++))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) data = table[c];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) userCount--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) bal += hSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) frameLeft--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) bal -= sSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) expand_data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) u_short *p = (u_short *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) u_short data = expand_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) while (frameLeft >= 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) u_char c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) if (bal < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) if (userCount < 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) if (get_user(c, userPtr++))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) data = table[c] << 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) if (get_user(c, userPtr++))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) data |= table[c];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) userCount -= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) bal += hSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) frameLeft -= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) bal -= sSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) expand_data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) expand_bal = bal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) used -= userCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) *frameUsed += usedf-frameLeft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) return used;
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) static ssize_t ata_ctx_s8(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) ssize_t frameLeft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) /* this should help gcc to stuff everything into registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) long bal = expand_bal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) long hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) ssize_t used, usedf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) used = userCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) usedf = frameLeft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) if (!dmasound.soft.stereo) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) u_char *p = &frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) u_char data = expand_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) while (frameLeft) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) if (bal < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) if (!userCount)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) if (get_user(data, userPtr++))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) userCount--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) bal += hSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) frameLeft--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) bal -= sSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) expand_data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) u_short *p = (u_short *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) u_short data = expand_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) while (frameLeft >= 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) if (bal < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) if (userCount < 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) if (get_user(data, (u_short __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) userPtr += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) userCount -= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) bal += hSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) frameLeft -= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) bal -= sSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) expand_data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) expand_bal = bal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) used -= userCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) *frameUsed += usedf-frameLeft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) return used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) static ssize_t ata_ctx_u8(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) ssize_t frameLeft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) /* this should help gcc to stuff everything into registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) long bal = expand_bal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) long hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) ssize_t used, usedf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) used = userCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) usedf = frameLeft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) if (!dmasound.soft.stereo) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) u_char *p = &frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) u_char data = expand_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) while (frameLeft) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) if (bal < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) if (!userCount)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) if (get_user(data, userPtr++))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) data ^= 0x80;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) userCount--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) bal += hSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) frameLeft--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) bal -= sSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) expand_data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) u_short *p = (u_short *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) u_short data = expand_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) while (frameLeft >= 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) if (bal < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) if (userCount < 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) if (get_user(data, (u_short __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) userPtr += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) data ^= 0x8080;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) userCount -= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) bal += hSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) frameLeft -= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) bal -= sSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) expand_data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) expand_bal = bal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) used -= userCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) *frameUsed += usedf-frameLeft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) return used;
^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 ssize_t ata_ctx_s16be(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) ssize_t frameLeft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) /* this should help gcc to stuff everything into registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) long bal = expand_bal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) long hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) ssize_t used, usedf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) used = userCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) usedf = frameLeft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) if (!dmasound.soft.stereo) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) u_short *p = (u_short *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) u_short data = expand_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) while (frameLeft >= 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) if (bal < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) if (userCount < 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) if (get_user(data, (u_short __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) userPtr += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) userCount -= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) bal += hSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) frameLeft -= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) bal -= sSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) expand_data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) u_long *p = (u_long *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) u_long data = expand_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) while (frameLeft >= 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) if (bal < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) if (userCount < 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) if (get_user(data, (u_int __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) userPtr += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) userCount -= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) bal += hSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) frameLeft -= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) bal -= sSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) expand_data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) expand_bal = bal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) used -= userCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) *frameUsed += usedf-frameLeft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) return used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) static ssize_t ata_ctx_u16be(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) ssize_t frameLeft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) /* this should help gcc to stuff everything into registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) long bal = expand_bal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) long hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) ssize_t used, usedf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) used = userCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) usedf = frameLeft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) if (!dmasound.soft.stereo) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) u_short *p = (u_short *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) u_short data = expand_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) while (frameLeft >= 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) if (bal < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) if (userCount < 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) if (get_user(data, (u_short __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) userPtr += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) data ^= 0x8000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) userCount -= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) bal += hSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) frameLeft -= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) bal -= sSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) expand_data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) u_long *p = (u_long *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) u_long data = expand_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) while (frameLeft >= 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) if (bal < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) if (userCount < 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) if (get_user(data, (u_int __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) userPtr += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) data ^= 0x80008000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) userCount -= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) bal += hSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) frameLeft -= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) bal -= sSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) expand_data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) expand_bal = bal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) used -= userCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) *frameUsed += usedf-frameLeft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) return used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) static ssize_t ata_ctx_s16le(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) ssize_t frameLeft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) /* this should help gcc to stuff everything into registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) long bal = expand_bal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) long hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) ssize_t used, usedf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) used = userCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) usedf = frameLeft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) if (!dmasound.soft.stereo) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) u_short *p = (u_short *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) u_short data = expand_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) while (frameLeft >= 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) if (bal < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) if (userCount < 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) if (get_user(data, (u_short __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) userPtr += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) data = le2be16(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) userCount -= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) bal += hSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) frameLeft -= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) bal -= sSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) expand_data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) u_long *p = (u_long *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) u_long data = expand_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) while (frameLeft >= 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) if (bal < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) if (userCount < 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) if (get_user(data, (u_int __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) userPtr += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) data = le2be16dbl(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) userCount -= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) bal += hSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) frameLeft -= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) bal -= sSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) expand_data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) expand_bal = bal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) used -= userCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) *frameUsed += usedf-frameLeft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) return used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) }
^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 ssize_t ata_ctx_u16le(const u_char __user *userPtr, size_t userCount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) u_char frame[], ssize_t *frameUsed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) ssize_t frameLeft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) /* this should help gcc to stuff everything into registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) long bal = expand_bal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) long hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) ssize_t used, usedf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) used = userCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) usedf = frameLeft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) if (!dmasound.soft.stereo) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) u_short *p = (u_short *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) u_short data = expand_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) while (frameLeft >= 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) if (bal < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) if (userCount < 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) if (get_user(data, (u_short __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) userPtr += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) data = le2be16(data) ^ 0x8000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) userCount -= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) bal += hSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) frameLeft -= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) bal -= sSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) expand_data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) u_long *p = (u_long *)&frame[*frameUsed];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) u_long data = expand_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) while (frameLeft >= 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) if (bal < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) if (userCount < 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) if (get_user(data, (u_int __user *)userPtr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) userPtr += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) data = le2be16dbl(data) ^ 0x80008000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) userCount -= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) bal += hSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) *p++ = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) frameLeft -= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) bal -= sSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) expand_data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) expand_bal = bal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) used -= userCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) *frameUsed += usedf-frameLeft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) return used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) static TRANS transTTNormal = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) .ct_ulaw = ata_ct_law,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) .ct_alaw = ata_ct_law,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) .ct_s8 = ata_ct_s8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) .ct_u8 = ata_ct_u8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) static TRANS transTTExpanding = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) .ct_ulaw = ata_ctx_law,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) .ct_alaw = ata_ctx_law,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) .ct_s8 = ata_ctx_s8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) .ct_u8 = ata_ctx_u8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) static TRANS transFalconNormal = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) .ct_ulaw = ata_ct_law,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) .ct_alaw = ata_ct_law,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) .ct_s8 = ata_ct_s8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) .ct_u8 = ata_ct_u8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) .ct_s16be = ata_ct_s16be,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) .ct_u16be = ata_ct_u16be,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) .ct_s16le = ata_ct_s16le,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) .ct_u16le = ata_ct_u16le
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) static TRANS transFalconExpanding = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) .ct_ulaw = ata_ctx_law,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) .ct_alaw = ata_ctx_law,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) .ct_s8 = ata_ctx_s8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) .ct_u8 = ata_ctx_u8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) .ct_s16be = ata_ctx_s16be,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) .ct_u16be = ata_ctx_u16be,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) .ct_s16le = ata_ctx_s16le,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) .ct_u16le = ata_ctx_u16le,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) /*** Low level stuff *********************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) * Atari (TT/Falcon)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) static void *AtaAlloc(unsigned int size, gfp_t flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) return atari_stram_alloc(size, "dmasound");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) static void AtaFree(void *obj, unsigned int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) atari_stram_free( obj );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) static int __init AtaIrqInit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) /* Set up timer A. Timer A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) will receive a signal upon end of playing from the sound
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) hardware. Furthermore Timer A is able to count events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) and will cause an interrupt after a programmed number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) of events. So all we need to keep the music playing is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) to provide the sound hardware with new data upon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) an interrupt from timer A. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) st_mfp.tim_ct_a = 0; /* ++roman: Stop timer before programming! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) st_mfp.tim_dt_a = 1; /* Cause interrupt after first event. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) st_mfp.tim_ct_a = 8; /* Turn on event counting. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) /* Register interrupt handler. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) if (request_irq(IRQ_MFP_TIMA, AtaInterrupt, 0, "DMA sound",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) AtaInterrupt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) st_mfp.int_en_a |= 0x20; /* Turn interrupt on. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) st_mfp.int_mk_a |= 0x20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) #ifdef MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) static void AtaIrqCleanUp(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) st_mfp.tim_ct_a = 0; /* stop timer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) st_mfp.int_en_a &= ~0x20; /* turn interrupt off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) free_irq(IRQ_MFP_TIMA, AtaInterrupt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) #endif /* MODULE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) #define TONE_VOXWARE_TO_DB(v) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) (((v) < 0) ? -12 : ((v) > 100) ? 12 : ((v) - 50) * 6 / 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) #define TONE_DB_TO_VOXWARE(v) (((v) * 25 + ((v) > 0 ? 5 : -5)) / 6 + 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) static int AtaSetBass(int bass)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) dmasound.bass = TONE_VOXWARE_TO_DB(bass);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) atari_microwire_cmd(MW_LM1992_BASS(dmasound.bass));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) return TONE_DB_TO_VOXWARE(dmasound.bass);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) static int AtaSetTreble(int treble)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) dmasound.treble = TONE_VOXWARE_TO_DB(treble);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) atari_microwire_cmd(MW_LM1992_TREBLE(dmasound.treble));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) return TONE_DB_TO_VOXWARE(dmasound.treble);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) * TT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) static void TTSilence(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) tt_dmasnd.ctrl = DMASND_CTRL_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) atari_microwire_cmd(MW_LM1992_PSG_HIGH); /* mix in PSG signal 1:1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) static void TTInit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) int mode, i, idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) const int freq[4] = {50066, 25033, 12517, 6258};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) /* search a frequency that fits into the allowed error range */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) idx = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) for (i = 0; i < ARRAY_SIZE(freq); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) /* this isn't as much useful for a TT than for a Falcon, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) * then it doesn't hurt very much to implement it for a TT too.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) if ((100 * abs(dmasound.soft.speed - freq[i]) / freq[i]) < catchRadius)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) idx = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) if (idx > -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) dmasound.soft.speed = freq[idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) dmasound.trans_write = &transTTNormal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) dmasound.trans_write = &transTTExpanding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) TTSilence();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) dmasound.hard = dmasound.soft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) if (dmasound.hard.speed > 50066) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) /* we would need to squeeze the sound, but we won't do that */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) dmasound.hard.speed = 50066;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) mode = DMASND_MODE_50KHZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) dmasound.trans_write = &transTTNormal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) } else if (dmasound.hard.speed > 25033) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) dmasound.hard.speed = 50066;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) mode = DMASND_MODE_50KHZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) } else if (dmasound.hard.speed > 12517) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) dmasound.hard.speed = 25033;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) mode = DMASND_MODE_25KHZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) } else if (dmasound.hard.speed > 6258) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) dmasound.hard.speed = 12517;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) mode = DMASND_MODE_12KHZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) dmasound.hard.speed = 6258;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) mode = DMASND_MODE_6KHZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) tt_dmasnd.mode = (dmasound.hard.stereo ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) DMASND_MODE_STEREO : DMASND_MODE_MONO) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) DMASND_MODE_8BIT | mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) expand_bal = -dmasound.soft.speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) static int TTSetFormat(int format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) /* TT sound DMA supports only 8bit modes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) switch (format) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) case AFMT_QUERY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) return dmasound.soft.format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) case AFMT_MU_LAW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) case AFMT_A_LAW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) case AFMT_S8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) case AFMT_U8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) format = AFMT_S8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) dmasound.soft.format = format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) dmasound.soft.size = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) if (dmasound.minDev == SND_DEV_DSP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) dmasound.dsp.format = format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) dmasound.dsp.size = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) TTInit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) return format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) #define VOLUME_VOXWARE_TO_DB(v) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) (((v) < 0) ? -40 : ((v) > 100) ? 0 : ((v) * 2) / 5 - 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) #define VOLUME_DB_TO_VOXWARE(v) ((((v) + 40) * 5 + 1) / 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) static int TTSetVolume(int volume)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) dmasound.volume_left = VOLUME_VOXWARE_TO_DB(volume & 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) atari_microwire_cmd(MW_LM1992_BALLEFT(dmasound.volume_left));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) dmasound.volume_right = VOLUME_VOXWARE_TO_DB((volume & 0xff00) >> 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) atari_microwire_cmd(MW_LM1992_BALRIGHT(dmasound.volume_right));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) return VOLUME_DB_TO_VOXWARE(dmasound.volume_left) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) (VOLUME_DB_TO_VOXWARE(dmasound.volume_right) << 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) #define GAIN_VOXWARE_TO_DB(v) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) (((v) < 0) ? -80 : ((v) > 100) ? 0 : ((v) * 4) / 5 - 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) #define GAIN_DB_TO_VOXWARE(v) ((((v) + 80) * 5 + 1) / 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) static int TTSetGain(int gain)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) dmasound.gain = GAIN_VOXWARE_TO_DB(gain);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) atari_microwire_cmd(MW_LM1992_VOLUME(dmasound.gain));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) return GAIN_DB_TO_VOXWARE(dmasound.gain);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) * Falcon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) static void FalconSilence(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) /* stop playback, set sample rate 50kHz for PSG sound */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) tt_dmasnd.ctrl = DMASND_CTRL_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) tt_dmasnd.mode = DMASND_MODE_50KHZ | DMASND_MODE_STEREO | DMASND_MODE_8BIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) tt_dmasnd.int_div = 0; /* STE compatible divider */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) tt_dmasnd.int_ctrl = 0x0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) tt_dmasnd.cbar_src = 0x0000; /* no matrix inputs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) tt_dmasnd.cbar_dst = 0x0000; /* no matrix outputs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) tt_dmasnd.dac_src = 1; /* connect ADC to DAC, disconnect matrix */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) tt_dmasnd.adc_src = 3; /* ADC Input = PSG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) static void FalconInit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) int divider, i, idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) const int freq[8] = {49170, 32780, 24585, 19668, 16390, 12292, 9834, 8195};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) /* search a frequency that fits into the allowed error range */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) idx = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) for (i = 0; i < ARRAY_SIZE(freq); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) /* if we will tolerate 3% error 8000Hz->8195Hz (2.38%) would
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) * be playable without expanding, but that now a kernel runtime
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) * option
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) if ((100 * abs(dmasound.soft.speed - freq[i]) / freq[i]) < catchRadius)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) idx = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) if (idx > -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) dmasound.soft.speed = freq[idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) dmasound.trans_write = &transFalconNormal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) dmasound.trans_write = &transFalconExpanding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) FalconSilence();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) dmasound.hard = dmasound.soft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) if (dmasound.hard.size == 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) /* the Falcon can play 16bit samples only in stereo */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) dmasound.hard.stereo = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) if (dmasound.hard.speed > 49170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) /* we would need to squeeze the sound, but we won't do that */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) dmasound.hard.speed = 49170;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) divider = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) dmasound.trans_write = &transFalconNormal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) } else if (dmasound.hard.speed > 32780) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) dmasound.hard.speed = 49170;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) divider = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) } else if (dmasound.hard.speed > 24585) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) dmasound.hard.speed = 32780;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) divider = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) } else if (dmasound.hard.speed > 19668) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) dmasound.hard.speed = 24585;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) divider = 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) } else if (dmasound.hard.speed > 16390) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) dmasound.hard.speed = 19668;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) divider = 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) } else if (dmasound.hard.speed > 12292) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) dmasound.hard.speed = 16390;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) divider = 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) } else if (dmasound.hard.speed > 9834) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) dmasound.hard.speed = 12292;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) divider = 7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) } else if (dmasound.hard.speed > 8195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) dmasound.hard.speed = 9834;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) divider = 9;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) dmasound.hard.speed = 8195;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) divider = 11;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) tt_dmasnd.int_div = divider;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) /* Setup Falcon sound DMA for playback */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) tt_dmasnd.int_ctrl = 0x4; /* Timer A int at play end */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) tt_dmasnd.track_select = 0x0; /* play 1 track, track 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) tt_dmasnd.cbar_src = 0x0001; /* DMA(25MHz) --> DAC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) tt_dmasnd.cbar_dst = 0x0000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) tt_dmasnd.rec_track_select = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) tt_dmasnd.dac_src = 2; /* connect matrix to DAC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) tt_dmasnd.adc_src = 0; /* ADC Input = Mic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) tt_dmasnd.mode = (dmasound.hard.stereo ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) DMASND_MODE_STEREO : DMASND_MODE_MONO) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) ((dmasound.hard.size == 8) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) DMASND_MODE_8BIT : DMASND_MODE_16BIT) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) DMASND_MODE_6KHZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) expand_bal = -dmasound.soft.speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) static int FalconSetFormat(int format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) int size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) /* Falcon sound DMA supports 8bit and 16bit modes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) switch (format) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) case AFMT_QUERY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) return dmasound.soft.format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) case AFMT_MU_LAW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) case AFMT_A_LAW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) case AFMT_U8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) case AFMT_S8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) size = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) case AFMT_S16_BE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) case AFMT_U16_BE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) case AFMT_S16_LE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) case AFMT_U16_LE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) size = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) default: /* :-) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) size = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) format = AFMT_S8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) dmasound.soft.format = format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) dmasound.soft.size = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) if (dmasound.minDev == SND_DEV_DSP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) dmasound.dsp.format = format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) dmasound.dsp.size = dmasound.soft.size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) FalconInit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) return format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) /* This is for the Falcon output *attenuation* in 1.5dB steps,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) * i.e. output level from 0 to -22.5dB in -1.5dB steps.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) #define VOLUME_VOXWARE_TO_ATT(v) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) ((v) < 0 ? 15 : (v) > 100 ? 0 : 15 - (v) * 3 / 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) #define VOLUME_ATT_TO_VOXWARE(v) (100 - (v) * 20 / 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) static int FalconSetVolume(int volume)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) dmasound.volume_left = VOLUME_VOXWARE_TO_ATT(volume & 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) dmasound.volume_right = VOLUME_VOXWARE_TO_ATT((volume & 0xff00) >> 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) tt_dmasnd.output_atten = dmasound.volume_left << 8 | dmasound.volume_right << 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) return VOLUME_ATT_TO_VOXWARE(dmasound.volume_left) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) VOLUME_ATT_TO_VOXWARE(dmasound.volume_right) << 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) static void AtaPlayNextFrame(int index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) char *start, *end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) /* used by AtaPlay() if all doubts whether there really is something
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) * to be played are already wiped out.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) start = write_sq.buffers[write_sq.front];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) end = start+((write_sq.count == index) ? write_sq.rear_size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) : write_sq.block_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) /* end might not be a legal virtual address. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) DMASNDSetEnd(virt_to_phys(end - 1) + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) DMASNDSetBase(virt_to_phys(start));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) /* Since only an even number of samples per frame can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) be played, we might lose one byte here. (TO DO) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) write_sq.front = (write_sq.front+1) % write_sq.max_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) write_sq.active++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) tt_dmasnd.ctrl = DMASND_CTRL_ON | DMASND_CTRL_REPEAT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) static void AtaPlay(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) /* ++TeSche: Note that write_sq.active is no longer just a flag but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) * holds the number of frames the DMA is currently programmed for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) * instead, may be 0, 1 (currently being played) or 2 (pre-programmed).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) * Changes done to write_sq.count and write_sq.active are a bit more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) * subtle again so now I must admit I also prefer disabling the irq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) * here rather than considering all possible situations. But the point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) * is that disabling the irq doesn't have any bad influence on this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) * version of the driver as we benefit from having pre-programmed the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) * DMA wherever possible: There's no need to reload the DMA at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) * exact time of an interrupt but only at some time while the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) * pre-programmed frame is playing!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) atari_disable_irq(IRQ_MFP_TIMA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) if (write_sq.active == 2 || /* DMA is 'full' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) write_sq.count <= 0) { /* nothing to do */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) atari_enable_irq(IRQ_MFP_TIMA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) if (write_sq.active == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) /* looks like there's nothing 'in' the DMA yet, so try
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) * to put two frames into it (at least one is available).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) if (write_sq.count == 1 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) write_sq.rear_size < write_sq.block_size &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) !write_sq.syncing) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) /* hmmm, the only existing frame is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) * yet filled and we're not syncing?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) atari_enable_irq(IRQ_MFP_TIMA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) AtaPlayNextFrame(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) if (write_sq.count == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) /* no more frames */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) atari_enable_irq(IRQ_MFP_TIMA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) if (write_sq.count == 2 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) write_sq.rear_size < write_sq.block_size &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) !write_sq.syncing) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) /* hmmm, there were two frames, but the second
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) * one is not yet filled and we're not syncing?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) atari_enable_irq(IRQ_MFP_TIMA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) AtaPlayNextFrame(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) /* there's already a frame being played so we may only stuff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) * one new into the DMA, but even if this may be the last
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) * frame existing the previous one is still on write_sq.count.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) if (write_sq.count == 2 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) write_sq.rear_size < write_sq.block_size &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) !write_sq.syncing) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) /* hmmm, the only existing frame is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) * yet filled and we're not syncing?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) atari_enable_irq(IRQ_MFP_TIMA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) AtaPlayNextFrame(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) atari_enable_irq(IRQ_MFP_TIMA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) static irqreturn_t AtaInterrupt(int irq, void *dummy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) /* ++TeSche: if you should want to test this... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) static int cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) if (write_sq.active == 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) if (++cnt == 10) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) /* simulate losing an interrupt */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) spin_lock(&dmasound.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) if (write_sq_ignore_int && is_falcon) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) /* ++TeSche: Falcon only: ignore first irq because it comes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) * immediately after starting a frame. after that, irqs come
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) * (almost) like on the TT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) write_sq_ignore_int = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) if (!write_sq.active) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) /* playing was interrupted and sq_reset() has already cleared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) * the sq variables, so better don't do anything here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) WAKE_UP(write_sq.sync_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) /* Probably ;) one frame is finished. Well, in fact it may be that a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) * pre-programmed one is also finished because there has been a long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) * delay in interrupt delivery and we've completely lost one, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) * there's no way to detect such a situation. In such a case the last
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) * frame will be played more than once and the situation will recover
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) * as soon as the irq gets through.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) write_sq.count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) write_sq.active--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) if (!write_sq.active) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) tt_dmasnd.ctrl = DMASND_CTRL_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) write_sq_ignore_int = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) WAKE_UP(write_sq.action_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) /* At least one block of the queue is free now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) so wake up a writing process blocked because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) of a full queue. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) if ((write_sq.active != 1) || (write_sq.count != 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) /* We must be a bit carefully here: write_sq.count indicates the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) * number of buffers used and not the number of frames to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) * played. If write_sq.count==1 and write_sq.active==1 that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) * means the only remaining frame was already programmed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) * earlier (and is currently running) so we mustn't call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) * AtaPlay() here, otherwise we'll play one frame too much.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) AtaPlay();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) if (!write_sq.active) WAKE_UP(write_sq.sync_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) /* We are not playing after AtaPlay(), so there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) is nothing to play any more. Wake up a process
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) waiting for audio output to drain. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) spin_unlock(&dmasound.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) /*** Mid level stuff *********************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) * /dev/mixer abstraction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) #define RECLEVEL_VOXWARE_TO_GAIN(v) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) ((v) < 0 ? 0 : (v) > 100 ? 15 : (v) * 3 / 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) #define RECLEVEL_GAIN_TO_VOXWARE(v) (((v) * 20 + 2) / 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) static void __init TTMixerInit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) atari_microwire_cmd(MW_LM1992_VOLUME(0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) dmasound.volume_left = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) atari_microwire_cmd(MW_LM1992_BALLEFT(0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) dmasound.volume_right = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) atari_microwire_cmd(MW_LM1992_BALRIGHT(0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) atari_microwire_cmd(MW_LM1992_TREBLE(0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) atari_microwire_cmd(MW_LM1992_BASS(0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) static void __init FalconMixerInit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) dmasound.volume_left = (tt_dmasnd.output_atten & 0xf00) >> 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) dmasound.volume_right = (tt_dmasnd.output_atten & 0xf0) >> 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) static int AtaMixerIoctl(u_int cmd, u_long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) int data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) case SOUND_MIXER_READ_SPEAKER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) if (is_falcon || MACH_IS_TT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) int porta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) spin_lock_irqsave(&dmasound.lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) sound_ym.rd_data_reg_sel = 14;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) porta = sound_ym.rd_data_reg_sel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) spin_unlock_irqrestore(&dmasound.lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) return IOCTL_OUT(arg, porta & 0x40 ? 0 : 100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) case SOUND_MIXER_WRITE_VOLUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) IOCTL_IN(arg, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) return IOCTL_OUT(arg, dmasound_set_volume(data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) case SOUND_MIXER_WRITE_SPEAKER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) if (is_falcon || MACH_IS_TT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) int porta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) IOCTL_IN(arg, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) spin_lock_irqsave(&dmasound.lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) sound_ym.rd_data_reg_sel = 14;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) porta = (sound_ym.rd_data_reg_sel & ~0x40) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) (data < 50 ? 0x40 : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) sound_ym.wd_data = porta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) spin_unlock_irqrestore(&dmasound.lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) return IOCTL_OUT(arg, porta & 0x40 ? 0 : 100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) static int TTMixerIoctl(u_int cmd, u_long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) int data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) case SOUND_MIXER_READ_RECMASK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) return IOCTL_OUT(arg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) case SOUND_MIXER_READ_DEVMASK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) return IOCTL_OUT(arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) SOUND_MASK_VOLUME | SOUND_MASK_TREBLE | SOUND_MASK_BASS |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) (MACH_IS_TT ? SOUND_MASK_SPEAKER : 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) case SOUND_MIXER_READ_STEREODEVS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) return IOCTL_OUT(arg, SOUND_MASK_VOLUME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) case SOUND_MIXER_READ_VOLUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) return IOCTL_OUT(arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) VOLUME_DB_TO_VOXWARE(dmasound.volume_left) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) (VOLUME_DB_TO_VOXWARE(dmasound.volume_right) << 8));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) case SOUND_MIXER_READ_BASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) return IOCTL_OUT(arg, TONE_DB_TO_VOXWARE(dmasound.bass));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) case SOUND_MIXER_READ_TREBLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) return IOCTL_OUT(arg, TONE_DB_TO_VOXWARE(dmasound.treble));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) case SOUND_MIXER_READ_OGAIN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) return IOCTL_OUT(arg, GAIN_DB_TO_VOXWARE(dmasound.gain));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) case SOUND_MIXER_WRITE_BASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) IOCTL_IN(arg, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) return IOCTL_OUT(arg, dmasound_set_bass(data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) case SOUND_MIXER_WRITE_TREBLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) IOCTL_IN(arg, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) return IOCTL_OUT(arg, dmasound_set_treble(data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) case SOUND_MIXER_WRITE_OGAIN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) IOCTL_IN(arg, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) return IOCTL_OUT(arg, dmasound_set_gain(data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) return AtaMixerIoctl(cmd, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) static int FalconMixerIoctl(u_int cmd, u_long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) int data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) case SOUND_MIXER_READ_RECMASK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) return IOCTL_OUT(arg, SOUND_MASK_MIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) case SOUND_MIXER_READ_DEVMASK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) return IOCTL_OUT(arg, SOUND_MASK_VOLUME | SOUND_MASK_MIC | SOUND_MASK_SPEAKER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) case SOUND_MIXER_READ_STEREODEVS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) return IOCTL_OUT(arg, SOUND_MASK_VOLUME | SOUND_MASK_MIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) case SOUND_MIXER_READ_VOLUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) return IOCTL_OUT(arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) VOLUME_ATT_TO_VOXWARE(dmasound.volume_left) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) VOLUME_ATT_TO_VOXWARE(dmasound.volume_right) << 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) case SOUND_MIXER_READ_CAPS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) return IOCTL_OUT(arg, SOUND_CAP_EXCL_INPUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) case SOUND_MIXER_WRITE_MIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) IOCTL_IN(arg, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) tt_dmasnd.input_gain =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) RECLEVEL_VOXWARE_TO_GAIN(data & 0xff) << 4 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) RECLEVEL_VOXWARE_TO_GAIN(data >> 8 & 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) fallthrough; /* return set value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) case SOUND_MIXER_READ_MIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) return IOCTL_OUT(arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) RECLEVEL_GAIN_TO_VOXWARE(tt_dmasnd.input_gain >> 4 & 0xf) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) RECLEVEL_GAIN_TO_VOXWARE(tt_dmasnd.input_gain & 0xf) << 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) return AtaMixerIoctl(cmd, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) static int AtaWriteSqSetup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) write_sq_ignore_int = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) return 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) static int AtaSqOpen(fmode_t mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) write_sq_ignore_int = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) return 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) static int TTStateInfo(char *buffer, size_t space)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) len += sprintf(buffer+len, "\tvol left %ddB [-40... 0]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) dmasound.volume_left);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) len += sprintf(buffer+len, "\tvol right %ddB [-40... 0]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) dmasound.volume_right);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) len += sprintf(buffer+len, "\tbass %ddB [-12...+12]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) dmasound.bass);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) len += sprintf(buffer+len, "\ttreble %ddB [-12...+12]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) dmasound.treble);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) if (len >= space) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) printk(KERN_ERR "dmasound_atari: overflowed state buffer alloc.\n") ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) len = space ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) static int FalconStateInfo(char *buffer, size_t space)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) len += sprintf(buffer+len, "\tvol left %ddB [-22.5 ... 0]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) dmasound.volume_left);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) len += sprintf(buffer+len, "\tvol right %ddB [-22.5 ... 0]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) dmasound.volume_right);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) if (len >= space) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) printk(KERN_ERR "dmasound_atari: overflowed state buffer alloc.\n") ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) len = space ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) /*** Machine definitions *****************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) static SETTINGS def_hard_falcon = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) .format = AFMT_S8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) .stereo = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) .size = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) .speed = 8195
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) } ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) static SETTINGS def_hard_tt = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) .format = AFMT_S8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) .stereo = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) .size = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) .speed = 12517
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) } ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) static SETTINGS def_soft = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) .format = AFMT_U8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) .stereo = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) .size = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) .speed = 8000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) } ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) static __initdata MACHINE machTT = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) .name = "Atari",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) .name2 = "TT",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) .dma_alloc = AtaAlloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) .dma_free = AtaFree,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) .irqinit = AtaIrqInit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) #ifdef MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) .irqcleanup = AtaIrqCleanUp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) #endif /* MODULE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) .init = TTInit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) .silence = TTSilence,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) .setFormat = TTSetFormat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) .setVolume = TTSetVolume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) .setBass = AtaSetBass,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) .setTreble = AtaSetTreble,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) .setGain = TTSetGain,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) .play = AtaPlay,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) .mixer_init = TTMixerInit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) .mixer_ioctl = TTMixerIoctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) .write_sq_setup = AtaWriteSqSetup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) .sq_open = AtaSqOpen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) .state_info = TTStateInfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) .min_dsp_speed = 6258,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) .version = ((DMASOUND_ATARI_REVISION<<8) | DMASOUND_ATARI_EDITION),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) .hardware_afmts = AFMT_S8, /* h'ware-supported formats *only* here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) .capabilities = DSP_CAP_BATCH /* As per SNDCTL_DSP_GETCAPS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) static __initdata MACHINE machFalcon = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) .name = "Atari",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) .name2 = "FALCON",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) .dma_alloc = AtaAlloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) .dma_free = AtaFree,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) .irqinit = AtaIrqInit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) #ifdef MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) .irqcleanup = AtaIrqCleanUp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) #endif /* MODULE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) .init = FalconInit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) .silence = FalconSilence,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) .setFormat = FalconSetFormat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) .setVolume = FalconSetVolume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) .setBass = AtaSetBass,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) .setTreble = AtaSetTreble,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) .play = AtaPlay,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) .mixer_init = FalconMixerInit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) .mixer_ioctl = FalconMixerIoctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) .write_sq_setup = AtaWriteSqSetup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) .sq_open = AtaSqOpen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) .state_info = FalconStateInfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) .min_dsp_speed = 8195,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) .version = ((DMASOUND_ATARI_REVISION<<8) | DMASOUND_ATARI_EDITION),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) .hardware_afmts = (AFMT_S8 | AFMT_S16_BE), /* h'ware-supported formats *only* here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) .capabilities = DSP_CAP_BATCH /* As per SNDCTL_DSP_GETCAPS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) /*** Config & Setup **********************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) static int __init dmasound_atari_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) if (MACH_IS_ATARI && ATARIHW_PRESENT(PCM_8BIT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) if (ATARIHW_PRESENT(CODEC)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) dmasound.mach = machFalcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) dmasound.mach.default_soft = def_soft ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) dmasound.mach.default_hard = def_hard_falcon ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) is_falcon = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) } else if (ATARIHW_PRESENT(MICROWIRE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) dmasound.mach = machTT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) dmasound.mach.default_soft = def_soft ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) dmasound.mach.default_hard = def_hard_tt ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) is_falcon = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) if ((st_mfp.int_en_a & st_mfp.int_mk_a & 0x20) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) return dmasound_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) printk("DMA sound driver: Timer A interrupt already in use\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) static void __exit dmasound_atari_cleanup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) dmasound_deinit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) module_init(dmasound_atari_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) module_exit(dmasound_atari_cleanup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) MODULE_LICENSE("GPL");