2019-06-08 11:02:36 +03:00
|
|
|
/* $NetBSD: tms320av110.c,v 1.27 2019/06/08 08:02:38 isaki Exp $ */
|
1997-10-17 03:58:10 +04:00
|
|
|
|
|
|
|
/*-
|
1999-02-17 02:34:10 +03:00
|
|
|
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
1999-02-17 01:46:55 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Ignatios Souvatzis.
|
1997-10-17 03:58:10 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
1999-02-17 01:46:55 +03:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
1997-10-17 03:58:10 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Machine independent part of TMS320AV110 driver.
|
|
|
|
*
|
|
|
|
* Currently, only minimum support for audio output. For audio/video
|
|
|
|
* synchronization, more is needed.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 16:14:31 +03:00
|
|
|
#include <sys/cdefs.h>
|
2019-06-08 11:02:36 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: tms320av110.c,v 1.27 2019/06/08 08:02:38 isaki Exp $");
|
2001-11-13 16:14:31 +03:00
|
|
|
|
1997-10-17 03:58:10 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
|
|
|
|
#include <sys/audioio.h>
|
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).
Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
2019-05-08 16:40:13 +03:00
|
|
|
#include <dev/audio/audio_if.h>
|
1997-10-17 03:58:10 +04:00
|
|
|
|
|
|
|
#include <dev/ic/tms320av110reg.h>
|
|
|
|
#include <dev/ic/tms320av110var.h>
|
|
|
|
|
2007-10-19 15:59:34 +04:00
|
|
|
#include <sys/bus.h>
|
1997-10-17 03:58:10 +04:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
void tav_close(void *);
|
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).
Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
2019-05-08 16:40:13 +03:00
|
|
|
int tav_query_format(void *, audio_format_query_t *);
|
|
|
|
int tav_set_format(void *, int,
|
|
|
|
const audio_params_t *, const audio_params_t *,
|
|
|
|
audio_filter_reg_t *, audio_filter_reg_t *);
|
2005-01-15 18:19:51 +03:00
|
|
|
int tav_round_blocksize(void *, int, int, const audio_params_t *);
|
|
|
|
int tav_start_output(void *, void *, int, void (*)(void *), void *);
|
|
|
|
int tav_start_input(void *, void *, int, void (*)(void *), void *);
|
|
|
|
int tav_halt_output(void *);
|
|
|
|
int tav_halt_input(void *);
|
|
|
|
int tav_speaker_ctl(void *, int);
|
|
|
|
int tav_getdev(void *, struct audio_device *);
|
|
|
|
int tav_set_port(void *, mixer_ctrl_t *);
|
|
|
|
int tav_get_port(void *, mixer_ctrl_t *);
|
|
|
|
int tav_query_devinfo(void *, mixer_devinfo_t *);
|
|
|
|
int tav_get_props(void *);
|
2011-11-24 03:07:28 +04:00
|
|
|
void tav_get_locks(void *, kmutex_t **, kmutex_t **);
|
1997-10-17 03:58:10 +04:00
|
|
|
|
2004-10-29 16:57:15 +04:00
|
|
|
const struct audio_hw_if tav_audio_if = {
|
2019-03-16 15:09:56 +03:00
|
|
|
.close = tav_close,
|
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).
Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
2019-05-08 16:40:13 +03:00
|
|
|
.query_format = tav_query_format,
|
|
|
|
.set_format = tav_set_format,
|
2019-03-16 15:09:56 +03:00
|
|
|
.round_blocksize = tav_round_blocksize,
|
|
|
|
.start_output = tav_start_output,
|
|
|
|
.start_input = tav_start_input,
|
|
|
|
.halt_output = tav_halt_output,
|
|
|
|
.halt_input = tav_halt_input,
|
|
|
|
.speaker_ctl = tav_speaker_ctl, /* optional */
|
|
|
|
.getdev = tav_getdev,
|
|
|
|
.set_port = tav_set_port,
|
|
|
|
.get_port = tav_get_port,
|
|
|
|
.query_devinfo = tav_query_devinfo,
|
|
|
|
.get_props = tav_get_props,
|
|
|
|
.get_locks = tav_get_locks,
|
1997-10-17 03:58:10 +04:00
|
|
|
};
|
|
|
|
|
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).
Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
2019-05-08 16:40:13 +03:00
|
|
|
/*
|
|
|
|
* XXX: The frequency might depend on the specific board.
|
|
|
|
* should be handled by the backend.
|
|
|
|
*/
|
|
|
|
#define TAV_FORMAT(prio, enc, prec) \
|
|
|
|
{ \
|
|
|
|
.priority = (prio), \
|
|
|
|
.mode = AUMODE_PLAY, \
|
|
|
|
.encoding = (enc), \
|
|
|
|
.validbits = (prec), \
|
|
|
|
.precision = (prec), \
|
|
|
|
.channels = 2, \
|
|
|
|
.channel_mask = AUFMT_STEREO, \
|
|
|
|
.frequency_type = 1, \
|
|
|
|
.frequency = { 44100 }, \
|
|
|
|
}
|
|
|
|
const struct audio_format tav_formats[] = {
|
|
|
|
TAV_FORMAT(-1, AUDIO_ENCODING_MPEG_L2_STREAM, 1),
|
|
|
|
TAV_FORMAT(-1, AUDIO_ENCODING_MPEG_L2_PACKETS, 1),
|
|
|
|
TAV_FORMAT(-1, AUDIO_ENCODING_MPEG_L2_SYSTEM, 1),
|
|
|
|
TAV_FORMAT( 0, AUDIO_ENCODING_SLINEAR_BE, 16),
|
|
|
|
};
|
|
|
|
#define TAV_NFORMATS __arraycount(tav_formats)
|
|
|
|
|
1997-10-17 03:58:10 +04:00
|
|
|
void
|
2005-01-15 18:19:51 +03:00
|
|
|
tms320av110_attach_mi(struct tav_softc *sc)
|
1997-10-17 03:58:10 +04:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
1997-10-17 03:58:10 +04:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
iot = sc->sc_iot;
|
|
|
|
ioh = sc->sc_ioh;
|
1997-10-17 03:58:10 +04:00
|
|
|
tav_write_byte(iot, ioh, TAV_RESET, 1);
|
|
|
|
while (tav_read_byte(iot, ioh, TAV_RESET))
|
|
|
|
delay(250);
|
|
|
|
|
|
|
|
tav_write_byte(iot, ioh, TAV_PCM_ORD, sc->sc_pcm_ord);
|
|
|
|
tav_write_byte(iot, ioh, TAV_PCM_18, sc->sc_pcm_18);
|
|
|
|
tav_write_byte(iot, ioh, TAV_DIF, sc->sc_dif);
|
|
|
|
tav_write_byte(iot, ioh, TAV_PCM_DIV, sc->sc_pcm_div);
|
|
|
|
|
|
|
|
printf(": chip rev. %d, %d bytes buffer\n",
|
|
|
|
tav_read_byte(iot, ioh, TAV_VERSION),
|
|
|
|
TAV_DRAM_SIZE(tav_read_byte(iot, ioh, TAV_DRAM_EXT)));
|
|
|
|
|
|
|
|
tav_write_byte(iot, ioh, TAV_AUD_ID_EN, 0);
|
|
|
|
tav_write_byte(iot, ioh, TAV_SKIP, 0);
|
|
|
|
tav_write_byte(iot, ioh, TAV_REPEAT, 0);
|
|
|
|
tav_write_byte(iot, ioh, TAV_MUTE, 0);
|
|
|
|
tav_write_byte(iot, ioh, TAV_PLAY, 1);
|
|
|
|
tav_write_byte(iot, ioh, TAV_SYNC_ECM, 0);
|
|
|
|
tav_write_byte(iot, ioh, TAV_CRC_ECM, 0);
|
|
|
|
tav_write_byte(iot, ioh, TAV_ATTEN_L, 0);
|
|
|
|
tav_write_byte(iot, ioh, TAV_ATTEN_R, 0);
|
1997-10-20 00:21:49 +04:00
|
|
|
tav_write_short(iot, ioh, TAV_FREE_FORM, 0);
|
1997-10-17 03:58:10 +04:00
|
|
|
tav_write_byte(iot, ioh, TAV_SIN_EN, 0);
|
|
|
|
tav_write_byte(iot, ioh, TAV_SYNC_ECM, TAV_ECM_REPEAT);
|
|
|
|
tav_write_byte(iot, ioh, TAV_CRC_ECM, TAV_ECM_REPEAT);
|
|
|
|
|
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).
Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
2019-05-08 16:40:13 +03:00
|
|
|
sc->sc_active = 0;
|
|
|
|
|
2012-10-27 21:17:22 +04:00
|
|
|
audio_attach_mi(&tav_audio_if, sc, sc->sc_dev);
|
1997-10-17 03:58:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-01-15 18:19:51 +03:00
|
|
|
tms320av110_intr(void *p)
|
1997-10-17 03:58:10 +04:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct tav_softc *sc;
|
|
|
|
uint16_t intlist;
|
1997-10-17 03:58:10 +04:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
sc = p;
|
2011-11-24 03:07:28 +04:00
|
|
|
|
|
|
|
mutex_spin_enter(&sc->sc_intr_lock);
|
|
|
|
|
1997-10-17 03:58:10 +04:00
|
|
|
intlist = tav_read_short(sc->sc_iot, sc->sc_ioh, TAV_INTR)
|
|
|
|
/* & tav_read_short(sc->sc_iot, sc->sc_ioh, TAV_INTR_EN)*/;
|
|
|
|
|
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).
Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
2019-05-08 16:40:13 +03:00
|
|
|
if (!intlist) {
|
|
|
|
mutex_spin_exit(&sc->sc_intr_lock);
|
1997-10-17 03:58:10 +04:00
|
|
|
return 0;
|
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).
Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
2019-05-08 16:40:13 +03:00
|
|
|
}
|
1997-10-17 03:58:10 +04:00
|
|
|
|
2003-01-06 16:04:54 +03:00
|
|
|
/* ack now, so that we don't miss later interrupts */
|
1997-10-17 03:58:10 +04:00
|
|
|
if (sc->sc_intack)
|
|
|
|
(sc->sc_intack)(sc);
|
|
|
|
|
|
|
|
if (intlist & TAV_INTR_LOWWATER) {
|
|
|
|
(*sc->sc_intr)(sc->sc_intrarg);
|
|
|
|
}
|
|
|
|
|
2011-11-24 03:07:28 +04:00
|
|
|
mutex_spin_exit(&sc->sc_intr_lock);
|
|
|
|
|
1997-10-17 03:58:10 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-01-15 18:19:51 +03:00
|
|
|
tav_close(void *hdl)
|
1997-10-17 03:58:10 +04:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct tav_softc *sc;
|
1997-10-17 03:58:10 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
|
|
|
|
|
|
|
sc = hdl;
|
|
|
|
iot = sc->sc_iot;
|
|
|
|
ioh = sc->sc_ioh;
|
|
|
|
|
2003-01-06 16:04:54 +03:00
|
|
|
/* re"start" chip, also clears interrupts and interrupt enable */
|
1997-10-17 03:58:10 +04:00
|
|
|
tav_write_short(iot, ioh, TAV_INTR_EN, 0);
|
|
|
|
if (sc->sc_intack)
|
|
|
|
(*sc->sc_intack)(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).
Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
2019-05-08 16:40:13 +03:00
|
|
|
tav_query_format(void *hdl, audio_format_query_t *afp)
|
1997-10-17 03:58:10 +04:00
|
|
|
{
|
2011-11-24 03:07:28 +04:00
|
|
|
|
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).
Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
2019-05-08 16:40:13 +03:00
|
|
|
return audio_query_format(tav_formats, TAV_NFORMATS, afp);
|
1997-10-17 03:58:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-01-15 18:19:51 +03:00
|
|
|
tav_start_input(void *hdl, void *block, int bsize,
|
|
|
|
void (*intr)(void *), void *intrarg)
|
1997-10-17 03:58:10 +04:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
|
1997-10-17 03:58:10 +04:00
|
|
|
return ENOTTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-01-15 18:19:51 +03:00
|
|
|
tav_halt_input(void *hdl)
|
1997-10-17 03:58:10 +04:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
|
1997-10-17 03:58:10 +04:00
|
|
|
return ENOTTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-01-15 18:19:51 +03:00
|
|
|
tav_start_output(void *hdl, void *block, int bsize,
|
|
|
|
void (*intr)(void *), void *intrarg)
|
1997-10-17 03:58:10 +04:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct tav_softc *sc;
|
1997-10-17 03:58:10 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
2005-01-15 18:19:51 +03:00
|
|
|
uint8_t *ptr;
|
1997-10-17 03:58:10 +04:00
|
|
|
int count;
|
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
sc = hdl;
|
1997-10-17 03:58:10 +04:00
|
|
|
iot = sc->sc_iot;
|
|
|
|
ioh = sc->sc_ioh;
|
|
|
|
ptr = block;
|
|
|
|
count = bsize;
|
2005-01-15 18:19:51 +03:00
|
|
|
|
1997-10-17 03:58:10 +04:00
|
|
|
sc->sc_intr = intr;
|
|
|
|
sc->sc_intrarg = intrarg;
|
|
|
|
|
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).
Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
2019-05-08 16:40:13 +03:00
|
|
|
if (sc->sc_active == 0) {
|
|
|
|
tav_write_byte(iot, ioh, TAV_PLAY, 1);
|
|
|
|
tav_write_byte(iot, ioh, TAV_MUTE, 0);
|
|
|
|
sc->sc_active = 1;
|
|
|
|
}
|
|
|
|
|
1997-10-20 23:07:59 +04:00
|
|
|
bus_space_write_multi_1(iot, ioh, TAV_DATAIN, ptr, count);
|
1997-10-17 03:58:10 +04:00
|
|
|
tav_write_short(iot, ioh, TAV_INTR_EN, TAV_INTR_LOWWATER);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-01-15 18:19:51 +03:00
|
|
|
tav_halt_output(void *hdl)
|
1997-10-17 03:58:10 +04:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct tav_softc *sc;
|
1997-10-17 03:58:10 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
sc = hdl;
|
1997-10-17 03:58:10 +04:00
|
|
|
iot = sc->sc_iot;
|
|
|
|
ioh = sc->sc_ioh;
|
|
|
|
|
|
|
|
tav_write_byte(iot, ioh, TAV_PLAY, 0);
|
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).
Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
2019-05-08 16:40:13 +03:00
|
|
|
sc->sc_active = 0;
|
1997-10-17 03:58:10 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-01-15 18:19:51 +03:00
|
|
|
tav_getdev(void *hdl, struct audio_device *ret)
|
1997-10-17 03:58:10 +04:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct tav_softc *sc;
|
1997-10-17 03:58:10 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
sc = hdl;
|
1997-10-17 03:58:10 +04:00
|
|
|
iot = sc->sc_iot;
|
|
|
|
ioh = sc->sc_ioh;
|
|
|
|
|
2004-04-22 04:17:10 +04:00
|
|
|
strlcpy(ret->name, "tms320av110", sizeof(ret->name));
|
|
|
|
/* guaranteed to be <= 4 in length */
|
|
|
|
snprintf(ret->version, sizeof(ret->version), "%u",
|
1997-10-17 03:58:10 +04:00
|
|
|
tav_read_byte(iot, ioh, TAV_VERSION));
|
2012-10-27 21:17:22 +04:00
|
|
|
strlcpy(ret->config, device_xname(sc->sc_dev), sizeof(ret->config));
|
1997-10-17 03:58:10 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-01-15 18:19:51 +03:00
|
|
|
tav_round_blocksize(void *hdl, int size, int mode, const audio_params_t *param)
|
1997-10-17 03:58:10 +04:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct tav_softc *sc;
|
1997-10-17 03:58:10 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
|
|
|
int maxhalf;
|
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
sc = hdl;
|
1997-10-17 03:58:10 +04:00
|
|
|
iot = sc->sc_iot;
|
|
|
|
ioh = sc->sc_ioh;
|
|
|
|
|
|
|
|
maxhalf = TAV_DRAM_HSIZE(tav_read_byte(iot, ioh, TAV_DRAM_EXT));
|
|
|
|
if (size > maxhalf)
|
|
|
|
size = maxhalf;
|
|
|
|
|
|
|
|
/* XXX should round to 128 bytes limits for audio bypass */
|
|
|
|
size &= ~3;
|
|
|
|
|
|
|
|
tav_write_short(iot, ioh, TAV_BALE_LIM, size/8);
|
|
|
|
|
|
|
|
/* the buffer limits are in units of 4 bytes */
|
|
|
|
return (size);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-01-15 18:19:51 +03:00
|
|
|
tav_get_props(void *hdl)
|
1997-10-17 03:58:10 +04:00
|
|
|
{
|
2019-06-08 11:02:36 +03:00
|
|
|
|
|
|
|
return AUDIO_PROP_PLAYBACK | AUDIO_PROP_CAPTURE;
|
1997-10-17 03:58:10 +04:00
|
|
|
}
|
|
|
|
|
2011-11-24 03:07:28 +04:00
|
|
|
void
|
|
|
|
tav_get_locks(void *hdl, kmutex_t **intr, kmutex_t **thread)
|
|
|
|
{
|
|
|
|
struct tav_softc *sc;
|
|
|
|
|
|
|
|
sc = hdl;
|
|
|
|
*intr = &sc->sc_intr_lock;
|
|
|
|
*thread = &sc->sc_lock;
|
|
|
|
}
|
|
|
|
|
1997-10-17 03:58:10 +04:00
|
|
|
int
|
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).
Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
2019-05-08 16:40:13 +03:00
|
|
|
tav_set_format(void *hdl, int setmode,
|
|
|
|
const audio_params_t *p, const audio_params_t *r,
|
|
|
|
audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
|
1997-10-17 03:58:10 +04:00
|
|
|
{
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
struct tav_softc *sc;
|
1997-10-17 03:58:10 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
|
|
|
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
sc = hdl;
|
1997-10-17 03:58:10 +04:00
|
|
|
iot = sc->sc_iot;
|
|
|
|
ioh = sc->sc_ioh;
|
|
|
|
|
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).
Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
2019-05-08 16:40:13 +03:00
|
|
|
KASSERT((setmode & AUMODE_PLAY));
|
|
|
|
KASSERT(p->encoding == AUDIO_ENCODING_SLINEAR_BE);
|
|
|
|
|
|
|
|
bus_space_write_1(iot, ioh, TAV_STR_SEL, TAV_STR_SEL_AUDIO_BYPASS);
|
1997-10-17 03:58:10 +04:00
|
|
|
|
|
|
|
tav_write_byte(iot, ioh, TAV_RESTART, 1);
|
|
|
|
do {
|
|
|
|
delay(10);
|
|
|
|
} while (tav_read_byte(iot, ioh, TAV_RESTART));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-01-15 18:19:51 +03:00
|
|
|
tav_set_port(void *hdl, mixer_ctrl_t *mc)
|
1997-10-17 03:58:10 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
/* dummy */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-01-15 18:19:51 +03:00
|
|
|
tav_get_port(void *hdl, mixer_ctrl_t *mc)
|
1997-10-17 03:58:10 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
/* dummy */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-01-15 18:19:51 +03:00
|
|
|
tav_query_devinfo(void *hdl, mixer_devinfo_t *di)
|
1997-10-17 03:58:10 +04:00
|
|
|
{
|
1997-10-19 11:41:33 +04:00
|
|
|
return ENXIO;
|
1997-10-17 03:58:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-01-15 18:19:51 +03:00
|
|
|
tav_speaker_ctl(void *hdl, int value)
|
1997-10-17 03:58:10 +04:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct tav_softc *sc;
|
1997-10-17 03:58:10 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
|
|
|
|
|
|
|
sc = hdl;
|
|
|
|
iot = sc->sc_iot;
|
|
|
|
ioh = sc->sc_ioh;
|
|
|
|
|
|
|
|
tav_write_byte(iot, ioh, TAV_MUTE, !value);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|