Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/isaki-audio2]: src/sys Adapt to audio2.
details: https://anonhg.NetBSD.org/src/rev/bd5cfa01e69c
branches: isaki-audio2
changeset: 455995:bd5cfa01e69c
user: isaki <isaki%NetBSD.org@localhost>
date: Thu Apr 25 13:49:39 2019 +0000
description:
Adapt to audio2.
- The sample rate seems to be determined by peripherals so
move uda1341_formats[] structure from ic/uda1341.c to audio_mini2440.c.
- XXX Resetting the device in open() (and close()) might be harmful
but I don't know details about what does this reset do.
diffstat:
sys/arch/evbarm/mini2440/audio_mini2440.c | 85 +++++++++++++-----------------
sys/dev/ic/uda1341.c | 69 +-----------------------
sys/dev/ic/uda1341var.h | 10 +--
3 files changed, 44 insertions(+), 120 deletions(-)
diffs (264 lines):
diff -r 629241fd7894 -r bd5cfa01e69c sys/arch/evbarm/mini2440/audio_mini2440.c
--- a/sys/arch/evbarm/mini2440/audio_mini2440.c Thu Apr 25 13:24:11 2019 +0000
+++ b/sys/arch/evbarm/mini2440/audio_mini2440.c Thu Apr 25 13:49:39 2019 +0000
@@ -72,8 +72,10 @@
int uda_ssio_open(void *, int);
void uda_ssio_close(void *);
-int uda_ssio_set_params(void *, int, int, audio_params_t *, audio_params_t *,
- stream_filter_list_t *, stream_filter_list_t *);
+int uda_ssio_query_format(void *, audio_format_query_t *);
+int uda_ssio_set_format(void *, int,
+ const audio_params_t *, const audio_params_t *,
+ audio_filter_reg_t *, audio_filter_reg_t *);
int uda_ssio_round_blocksize(void *, int, int, const audio_params_t *);
int uda_ssio_start_output(void *, void *, int, void (*)(void *),
void *);
@@ -91,8 +93,8 @@
struct audio_hw_if uda1341_hw_if = {
.open = uda_ssio_open,
.close = uda_ssio_close,
- .query_encoding = uda1341_query_encodings,
- .set_params = uda_ssio_set_params,
+ .query_format = uda_ssio_query_format,
+ .set_format = uda_ssio_set_format,
.round_blocksize = uda_ssio_round_blocksize,
.start_output = uda_ssio_start_output,
.start_input = uda_ssio_start_input,
@@ -115,6 +117,21 @@
"uda_ssio"
};
+static const struct audio_format uda_ssio_formats[] =
+{
+ {
+ .mode = AUMODE_PLAY | AUMODE_RECORD,
+ .encoding = AUDIO_ENCODING_SLINEAR_LE,
+ .validbits = 16,
+ .precision = 16,
+ .channels = 2,
+ .channel_mask = AUFMT_STEREO,
+ .frequency_type = 6,
+ .frequency = { 8000, 11025, 22050, 32000, 44100, 48000 },
+ }
+};
+#define UDA_SSIO_NFORMATS __arraycount(uda_ssio_formats)
+
void uda_ssio_l3_write(void *,int mode, int value);
int uda_ssio_match(device_t, cfdata_t, void*);
@@ -233,54 +250,28 @@
}
int
-uda_ssio_set_params(void *handle, int setmode, int usemode,
- audio_params_t *play, audio_params_t *rec,
- stream_filter_list_t *pfil, stream_filter_list_t *rfil)
+uda_ssio_query_format(void *handle, audio_format_query_t *afp)
+{
+
+ return audio_query_format(uda_ssio_formats, UDA_SSIO_NFORMATS, afp);
+}
+
+int
+uda_ssio_set_format(void *handle, int setmode,
+ const audio_params_t *play, const audio_params_t *rec,
+ audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
{
struct uda1341_softc *uc = handle;
struct uda_softc *sc = uc->parent;
- const struct audio_format *selected_format;
- audio_params_t *params;
- stream_filter_list_t *fil;
int retval;
DPRINTF(("%s: setmode: %d\n", __func__, setmode));
- DPRINTF(("%s: usemode: %d\n", __func__, usemode));
- if (setmode == 0)
- setmode = usemode;
-
- if (setmode & AUMODE_PLAY) {
- params = play;
- fil = pfil;
- } else if (setmode == AUMODE_RECORD) {
- params = rec;
- fil = rfil;
- } else {
- return EINVAL;
- }
+ /* *play and *rec are the identical because !AUDIO_PROP_INDEPENDENT. */
DPRINTF(("%s: %dHz, encoding: %d, precision: %d, channels: %d\n",
- __func__, params->sample_rate, params->encoding, play->precision,
- params->channels));
-
- if (params->sample_rate != 8000 &&
- params->sample_rate != 11025 &&
- params->sample_rate != 22050 &&
- params->sample_rate != 32000 &&
- params->sample_rate != 44100 &&
- params->sample_rate != 48000) {
- return EINVAL;
- }
-
- retval = auconv_set_converter(uda1341_formats, UDA1341_NFORMATS,
- setmode, params, true, fil);
- if (retval < 0) {
- printf("Could not find valid format\n");
- return EINVAL;
- }
-
- selected_format = &uda1341_formats[retval];
+ __func__, play->sample_rate, play->encoding, play->precision,
+ play->channels));
if (setmode == AUMODE_PLAY) {
s3c2440_i2s_set_direction(sc->sc_i2s_handle,
@@ -290,9 +281,8 @@
S3C2440_I2S_RECEIVE);
}
- s3c2440_i2s_set_sample_rate(sc->sc_i2s_handle, params->sample_rate);
- s3c2440_i2s_set_sample_width(sc->sc_i2s_handle,
- selected_format->precision);
+ s3c2440_i2s_set_sample_rate(sc->sc_i2s_handle, play->sample_rate);
+ s3c2440_i2s_set_sample_width(sc->sc_i2s_handle, 16);
/* It is vital that sc_system_clock is set PRIOR to calling
uda1341_set_params. */
@@ -307,8 +297,7 @@
return EINVAL;
}
- retval = uda1341_set_params(handle, setmode, usemode,
- play, rec, pfil, rfil);
+ retval = uda1341_set_format(handle, setmode, play, rec, pfil, rfil);
if (retval != 0) {
return retval;
}
diff -r 629241fd7894 -r bd5cfa01e69c sys/dev/ic/uda1341.c
--- a/sys/dev/ic/uda1341.c Thu Apr 25 13:24:11 2019 +0000
+++ b/sys/dev/ic/uda1341.c Thu Apr 25 13:49:39 2019 +0000
@@ -47,25 +47,6 @@
#define DPRINTF(s) do {} while (/*CONSTCOND*/0)
#endif
-#define UDA1341_FORMAT(enc, prec) \
- { \
- .mode = AUMODE_PLAY | AUMODE_RECORD, \
- .encoding = (enc), \
- .validbits = (prec), \
- .precision = (prec), \
- .channels = 2, \
- .channel_mask = AUFMT_STEREO, \
- .frequency_type = 0, \
- .frequency = { 8000, 48000 }, \
- }
-const struct audio_format uda1341_formats[UDA1341_NFORMATS] =
-{
- UDA1341_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 8),
- UDA1341_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16),
- UDA1341_FORMAT(AUDIO_ENCODING_ULINEAR_LE, 8),
- UDA1341_FORMAT(AUDIO_ENCODING_ULINEAR_LE, 16),
-};
-
static void uda1341_update_sound_settings(struct uda1341_softc *sc);
@@ -95,48 +76,6 @@
}
int
-uda1341_query_encodings(void *handle, audio_encoding_t *ae)
-{
- switch(ae->index) {
- case 0:
- strlcpy(ae->name, AudioEmulaw, sizeof(ae->name));
- ae->encoding = AUDIO_ENCODING_ULAW;
- ae->precision = 8;
- ae->flags = AUDIO_ENCODINGFLAG_EMULATED;
- break;
- case 1:
- strlcpy(ae->name, AudioEslinear_le, sizeof(ae->name));
- ae->encoding = AUDIO_ENCODING_SLINEAR_LE;
- ae->precision = 8;
- ae->flags = 0;
- break;
- case 2:
- strlcpy(ae->name, AudioEslinear_le, sizeof(ae->name));
- ae->encoding = AUDIO_ENCODING_SLINEAR_LE;
- ae->precision = 16;
- ae->flags = 0;
- break;
- case 3:
- strlcpy(ae->name, AudioEulinear_le, sizeof(ae->name));
- ae->encoding = AUDIO_ENCODING_ULINEAR_LE;
- ae->precision = 8;
- ae->flags = 0;
- break;
- case 4:
- strlcpy(ae->name, AudioEulinear_le, sizeof(ae->name));
- ae->encoding = AUDIO_ENCODING_ULINEAR_LE;
- ae->precision = 16;
- ae->flags = 0;
- break;
-
- default:
- return EINVAL;
- }
-
- return 0;
-}
-
-int
uda1341_open(void *handle, int flags)
{
struct uda1341_softc *sc = handle;
@@ -188,13 +127,13 @@
}
int
-uda1341_set_params(void *handle, int setmode, int usemode,
- audio_params_t *play, audio_params_t *rec,
- stream_filter_list_t *pfil, stream_filter_list_t *rfil)
+uda1341_set_format(void *handle, int setmode,
+ const audio_params_t *play, const audio_params_t *rec,
+ audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
{
struct uda1341_softc *sc = handle;
if (sc->sc_system_clock == UDA1341_CLOCK_NA)
- panic("uda1341_set_params was called without sc_system_clock set!\n");
+ panic("%s was called without sc_system_clock set!\n", __func__);
/* Select status register */
sc->sc_l3_write(sc, 0, UDA1341_L3_ADDR_DEVICE |
diff -r 629241fd7894 -r bd5cfa01e69c sys/dev/ic/uda1341var.h
--- a/sys/dev/ic/uda1341var.h Thu Apr 25 13:24:11 2019 +0000
+++ b/sys/dev/ic/uda1341var.h Thu Apr 25 13:49:39 2019 +0000
@@ -32,11 +32,6 @@
#include <sys/device.h>
#include <sys/audioio.h>
-#include <dev/auconv.h>
-
-#define UDA1341_NFORMATS 4
-extern const struct audio_format uda1341_formats[UDA1341_NFORMATS];
-
struct uda1341_softc {
/* Pointer to the driver that holds this sc */
void *parent;
@@ -85,10 +80,11 @@
};
int uda1341_attach(struct uda1341_softc *);
-int uda1341_query_encodings(void *, audio_encoding_t *);
int uda1341_open(void *, int );
void uda1341_close(void *);
-int uda1341_set_params(void *, int, int, audio_params_t*, audio_params_t*, stream_filter_list_t *, stream_filter_list_t*);
+int uda1341_set_format(void *, int,
+ const audio_params_t *, const audio_params_t *,
+ audio_filter_reg_t *, audio_filter_reg_t *);
int uda1341_query_devinfo(void *, mixer_devinfo_t *);
int uda1341_get_port(void *, mixer_ctrl_t *);
int uda1341_set_port(void *, mixer_ctrl_t *);
Home |
Main Index |
Thread Index |
Old Index