^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* -*- linux-c -*- *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * ALSA driver for the digigram lx6464es interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (c) 2009 Tim Blechmann <tim@klingt.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #ifndef LX6464ES_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define LX6464ES_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/atomic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <sound/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <sound/pcm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "lx_core.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define LXP "LX6464ES: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) ES_cmd_free = 0, /* no command executing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) ES_cmd_processing = 1, /* execution of a read/write command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) ES_read_pending = 2, /* a asynchron read command is pending */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) ES_read_finishing = 3, /* a read command has finished waiting (set by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * Interrupt or CancelIrp) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) enum lx_stream_status {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) LX_STREAM_STATUS_FREE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) /* LX_STREAM_STATUS_OPEN, */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) LX_STREAM_STATUS_SCHEDULE_RUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) /* LX_STREAM_STATUS_STARTED, */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) LX_STREAM_STATUS_RUNNING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) LX_STREAM_STATUS_SCHEDULE_STOP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) /* LX_STREAM_STATUS_STOPPED, */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /* LX_STREAM_STATUS_PAUSED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct lx_stream {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct snd_pcm_substream *stream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) snd_pcm_uframes_t frame_pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) enum lx_stream_status status; /* free, open, running, draining
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * pause */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) unsigned int is_capture:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct lx6464es {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct snd_card *card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct pci_dev *pci;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) u8 mac_address[6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct mutex lock; /* interrupt lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct mutex setup_mutex; /* mutex used in hw_params, open
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * and close */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /* ports */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) unsigned long port_plx; /* io port (size=256) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) void __iomem *port_plx_remapped; /* remapped plx port */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) void __iomem *port_dsp_bar; /* memory port (32-bit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * non-prefetchable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * size=8K) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) /* messaging */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct mutex msg_lock; /* message lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct lx_rmh rmh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) u32 irqsrc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /* configuration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) uint freq_ratio : 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) uint playback_mute : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) uint hardware_running[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) u32 board_sample_rate; /* sample rate read from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * board */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) u16 pcm_granularity; /* board blocksize */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) /* dma */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct snd_dma_buffer capture_dma_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct snd_dma_buffer playback_dma_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) /* pcm */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct snd_pcm *pcm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /* streams */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) struct lx_stream capture_stream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) struct lx_stream playback_stream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) #endif /* LX6464ES_H */