Commit 521b2e11 authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Takashi Iwai

ALSA: oxfw: set packet parameter according to current configuration

After a call of pcm.hw_params, the state of target device is expected
for applications. This commit retrieves the state and start packet
streaming.
Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent da2af86d
...@@ -112,51 +112,51 @@ static void stop_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream) ...@@ -112,51 +112,51 @@ static void stop_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream)
cmp_connection_break(&oxfw->in_conn); cmp_connection_break(&oxfw->in_conn);
} }
static int start_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream, static int start_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream)
unsigned int rate, unsigned int pcm_channels)
{ {
u8 **formats; u8 **formats;
enum avc_general_plug_dir dir;
struct cmp_connection *conn; struct cmp_connection *conn;
struct snd_oxfw_stream_formation formation; struct snd_oxfw_stream_formation formation;
unsigned int i, midi_ports; int i;
int err; int err;
if (stream == &oxfw->rx_stream) { if (stream == &oxfw->rx_stream) {
dir = AVC_GENERAL_PLUG_DIR_IN;
formats = oxfw->rx_stream_formats; formats = oxfw->rx_stream_formats;
conn = &oxfw->in_conn; conn = &oxfw->in_conn;
} else { } else {
dir = AVC_GENERAL_PLUG_DIR_OUT;
formats = oxfw->tx_stream_formats; formats = oxfw->tx_stream_formats;
conn = &oxfw->out_conn; conn = &oxfw->out_conn;
} }
/* Get stream format */ err = snd_oxfw_stream_get_current_formation(oxfw, dir, &formation);
if (err < 0)
return err;
for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) { for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) {
struct snd_oxfw_stream_formation fmt;
if (formats[i] == NULL) if (formats[i] == NULL)
break; break;
err = snd_oxfw_stream_parse_format(formats[i], &formation); err = snd_oxfw_stream_parse_format(formats[i], &fmt);
if (err < 0) if (err < 0)
goto end; return err;
if (rate != formation.rate) if (fmt.rate == formation.rate && fmt.pcm == formation.pcm &&
continue; fmt.midi == formation.midi)
if (pcm_channels == 0 || pcm_channels == formation.pcm)
break; break;
} }
if (i == SND_OXFW_STREAM_FORMAT_ENTRIES) { if (i == SND_OXFW_STREAM_FORMAT_ENTRIES)
err = -EINVAL; return -EINVAL;
goto end;
}
pcm_channels = formation.pcm; // The stream should have one pcm channels at least.
midi_ports = formation.midi * 8; if (formation.pcm == 0)
return -EINVAL;
/* The stream should have one pcm channels at least */ err = amdtp_am824_set_parameters(stream, formation.rate, formation.pcm,
if (pcm_channels == 0) { formation.midi * 8, false);
err = -EINVAL;
goto end;
}
err = amdtp_am824_set_parameters(stream, rate, pcm_channels, midi_ports,
false);
if (err < 0) if (err < 0)
goto end; goto end;
...@@ -316,7 +316,7 @@ int snd_oxfw_stream_start_simplex(struct snd_oxfw *oxfw, ...@@ -316,7 +316,7 @@ int snd_oxfw_stream_start_simplex(struct snd_oxfw *oxfw,
/* Start opposite stream if needed. */ /* Start opposite stream if needed. */
if (opposite && !amdtp_stream_running(opposite) && if (opposite && !amdtp_stream_running(opposite) &&
(opposite_substreams > 0)) { (opposite_substreams > 0)) {
err = start_stream(oxfw, opposite, rate, 0); err = start_stream(oxfw, opposite);
if (err < 0) { if (err < 0) {
dev_err(&oxfw->unit->device, dev_err(&oxfw->unit->device,
"fail to restart stream: %d\n", err); "fail to restart stream: %d\n", err);
...@@ -327,7 +327,7 @@ int snd_oxfw_stream_start_simplex(struct snd_oxfw *oxfw, ...@@ -327,7 +327,7 @@ int snd_oxfw_stream_start_simplex(struct snd_oxfw *oxfw,
/* Start requested stream. */ /* Start requested stream. */
if (!amdtp_stream_running(stream)) { if (!amdtp_stream_running(stream)) {
err = start_stream(oxfw, stream, rate, pcm_channels); err = start_stream(oxfw, stream);
if (err < 0) if (err < 0)
dev_err(&oxfw->unit->device, dev_err(&oxfw->unit->device,
"fail to start stream: %d\n", err); "fail to start stream: %d\n", err);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment