1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 * ALSA driver for the digigram lx6464es interface
7 * Copyright (c) 2009 Tim Blechmann <tim@klingt.org>
13 #include <linux/interrupt.h>
17 #define REG_CRM_NUMBER 12
21 /* low-level register access */
23 /* dsp register access */
59 unsigned long lx_dsp_reg_read(struct lx6464es
*chip
, int port
);
60 void lx_dsp_reg_write(struct lx6464es
*chip
, int port
, unsigned data
);
62 /* plx register access */
82 unsigned long lx_plx_reg_read(struct lx6464es
*chip
, int port
);
83 void lx_plx_reg_write(struct lx6464es
*chip
, int port
, u32 data
);
87 u16 cmd_len
; /* length of the command to send (WORDs) */
88 u16 stat_len
; /* length of the status received (WORDs) */
89 u16 dsp_stat
; /* status type, RMP_SSIZE_XXX */
90 u16 cmd_idx
; /* index of the command */
91 u32 cmd
[REG_CRM_NUMBER
];
92 u32 stat
[REG_CRM_NUMBER
];
96 /* low-level dsp access */
97 int lx_dsp_get_version(struct lx6464es
*chip
, u32
*rdsp_version
);
98 int lx_dsp_get_clock_frequency(struct lx6464es
*chip
, u32
*rfreq
);
99 int lx_dsp_set_granularity(struct lx6464es
*chip
, u32 gran
);
100 int lx_dsp_read_async_events(struct lx6464es
*chip
, u32
*data
);
101 int lx_dsp_get_mac(struct lx6464es
*chip
);
104 /* low-level pipe handling */
105 int lx_pipe_allocate(struct lx6464es
*chip
, u32 pipe
, int is_capture
,
107 int lx_pipe_release(struct lx6464es
*chip
, u32 pipe
, int is_capture
);
108 int lx_pipe_sample_count(struct lx6464es
*chip
, u32 pipe
, int is_capture
,
110 int lx_pipe_state(struct lx6464es
*chip
, u32 pipe
, int is_capture
, u16
*rstate
);
111 int lx_pipe_stop(struct lx6464es
*chip
, u32 pipe
, int is_capture
);
112 int lx_pipe_start(struct lx6464es
*chip
, u32 pipe
, int is_capture
);
113 int lx_pipe_pause(struct lx6464es
*chip
, u32 pipe
, int is_capture
);
115 int lx_pipe_wait_for_start(struct lx6464es
*chip
, u32 pipe
, int is_capture
);
116 int lx_pipe_wait_for_idle(struct lx6464es
*chip
, u32 pipe
, int is_capture
);
118 /* low-level stream handling */
119 int lx_stream_set_format(struct lx6464es
*chip
, struct snd_pcm_runtime
*runtime
,
120 u32 pipe
, int is_capture
);
121 int lx_stream_state(struct lx6464es
*chip
, u32 pipe
, int is_capture
,
123 int lx_stream_sample_position(struct lx6464es
*chip
, u32 pipe
, int is_capture
,
126 int lx_stream_set_state(struct lx6464es
*chip
, u32 pipe
,
127 int is_capture
, enum stream_state_t state
);
129 static inline int lx_stream_start(struct lx6464es
*chip
, u32 pipe
,
132 snd_printdd("->lx_stream_start\n");
133 return lx_stream_set_state(chip
, pipe
, is_capture
, SSTATE_RUN
);
136 static inline int lx_stream_pause(struct lx6464es
*chip
, u32 pipe
,
139 snd_printdd("->lx_stream_pause\n");
140 return lx_stream_set_state(chip
, pipe
, is_capture
, SSTATE_PAUSE
);
143 static inline int lx_stream_stop(struct lx6464es
*chip
, u32 pipe
,
146 snd_printdd("->lx_stream_stop\n");
147 return lx_stream_set_state(chip
, pipe
, is_capture
, SSTATE_STOP
);
150 /* low-level buffer handling */
151 int lx_buffer_ask(struct lx6464es
*chip
, u32 pipe
, int is_capture
,
152 u32
*r_needed
, u32
*r_freed
, u32
*size_array
);
153 int lx_buffer_give(struct lx6464es
*chip
, u32 pipe
, int is_capture
,
154 u32 buffer_size
, u32 buf_address_lo
, u32 buf_address_hi
,
155 u32
*r_buffer_index
);
156 int lx_buffer_free(struct lx6464es
*chip
, u32 pipe
, int is_capture
,
158 int lx_buffer_cancel(struct lx6464es
*chip
, u32 pipe
, int is_capture
,
161 /* low-level gain/peak handling */
162 int lx_level_unmute(struct lx6464es
*chip
, int is_capture
, int unmute
);
163 int lx_level_peaks(struct lx6464es
*chip
, int is_capture
, int channels
,
167 /* interrupt handling */
168 irqreturn_t
lx_interrupt(int irq
, void *dev_id
);
169 irqreturn_t
lx_threaded_irq(int irq
, void *dev_id
);
170 void lx_irq_enable(struct lx6464es
*chip
);
171 void lx_irq_disable(struct lx6464es
*chip
);
174 /* Stream Format Header Defines (for LIN and IEEE754) */
175 #define HEADER_FMT_BASE HEADER_FMT_BASE_LIN
176 #define HEADER_FMT_BASE_LIN 0xFED00000
177 #define HEADER_FMT_BASE_FLOAT 0xFAD00000
178 #define HEADER_FMT_MONO 0x00000080 /* bit 23 in header_lo. WARNING: old
179 * bit 22 is ignored in float
181 #define HEADER_FMT_INTEL 0x00008000
182 #define HEADER_FMT_16BITS 0x00002000
183 #define HEADER_FMT_24BITS 0x00004000
184 #define HEADER_FMT_UPTO11 0x00000200 /* frequency is less or equ. to 11k.
186 #define HEADER_FMT_UPTO32 0x00000100 /* frequency is over 11k and less
190 #define BIT_FMP_HEADER 23
191 #define BIT_FMP_SD 22
192 #define BIT_FMP_MULTICHANNEL 19
194 #define START_STATE 1
195 #define PAUSE_STATE 0
201 /* from PcxAll_e.h */
202 /* Start/Pause condition for pipes (PCXStartPipe, PCXPausePipe) */
203 #define START_PAUSE_IMMEDIATE 0
204 #define START_PAUSE_ON_SYNCHRO 1
205 #define START_PAUSE_ON_TIME_CODE 2
208 /* Pipe / Stream state */
209 #define START_STATE 1
210 #define PAUSE_STATE 0
212 static inline void unpack_pointer(dma_addr_t ptr
, u32
*r_low
, u32
*r_high
)
214 *r_low
= (u32
)(ptr
& 0xffffffff);
215 #if BITS_PER_LONG == 32
218 *r_high
= (u32
)((u64
)ptr
>>32);
222 #endif /* LX_CORE_H */