Commit 547e631c authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Takashi Iwai

ALSA: firewire-lib: return error code when amdtp_stream_set_parameters() detects error

Currently, amdtp_stream_set_parameters() returns no error even if wrong
arguments are given. This is not good for streaming layer because drivers
can continue processing ignoring capability of streaming layer.

This commit changes this function to return error code.
Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 10b2b6dc
......@@ -197,10 +197,10 @@ EXPORT_SYMBOL(amdtp_stream_add_pcm_hw_constraints);
* The parameters must be set before the stream is started, and must not be
* changed while the stream is running.
*/
void amdtp_stream_set_parameters(struct amdtp_stream *s,
unsigned int rate,
unsigned int pcm_channels,
unsigned int midi_ports)
int amdtp_stream_set_parameters(struct amdtp_stream *s,
unsigned int rate,
unsigned int pcm_channels,
unsigned int midi_ports)
{
unsigned int i, sfc, midi_channels;
......@@ -209,15 +209,15 @@ void amdtp_stream_set_parameters(struct amdtp_stream *s,
if (WARN_ON(amdtp_stream_running(s)) |
WARN_ON(pcm_channels > AMDTP_MAX_CHANNELS_FOR_PCM) |
WARN_ON(midi_channels > AMDTP_MAX_CHANNELS_FOR_MIDI))
return;
return -EINVAL;
for (sfc = 0; sfc < ARRAY_SIZE(amdtp_rate_table); ++sfc)
for (sfc = 0; sfc < ARRAY_SIZE(amdtp_rate_table); ++sfc) {
if (amdtp_rate_table[sfc] == rate)
goto sfc_found;
WARN_ON(1);
return;
break;
}
if (sfc == ARRAY_SIZE(amdtp_rate_table))
return -EINVAL;
sfc_found:
s->pcm_channels = pcm_channels;
s->sfc = sfc;
s->data_block_quadlets = s->pcm_channels + midi_channels;
......@@ -243,6 +243,8 @@ void amdtp_stream_set_parameters(struct amdtp_stream *s,
* (The value here is adjusted for midi_ratelimit_per_packet().)
*/
s->midi_fifo_limit = rate - MIDI_BYTES_PER_SECOND * s->syt_interval + 1;
return 0;
}
EXPORT_SYMBOL(amdtp_stream_set_parameters);
......
......@@ -174,10 +174,10 @@ int amdtp_stream_init(struct amdtp_stream *s, struct fw_unit *unit,
enum cip_flags flags);
void amdtp_stream_destroy(struct amdtp_stream *s);
void amdtp_stream_set_parameters(struct amdtp_stream *s,
unsigned int rate,
unsigned int pcm_channels,
unsigned int midi_ports);
int amdtp_stream_set_parameters(struct amdtp_stream *s,
unsigned int rate,
unsigned int pcm_channels,
unsigned int midi_ports);
unsigned int amdtp_stream_get_max_payload(struct amdtp_stream *s);
int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed);
......
......@@ -427,12 +427,17 @@ make_both_connections(struct snd_bebob *bebob, unsigned int rate)
index = get_formation_index(rate);
pcm_channels = bebob->tx_stream_formations[index].pcm;
midi_channels = bebob->tx_stream_formations[index].midi;
amdtp_stream_set_parameters(&bebob->tx_stream,
rate, pcm_channels, midi_channels * 8);
err = amdtp_stream_set_parameters(&bebob->tx_stream, rate,
pcm_channels, midi_channels * 8);
if (err < 0)
goto end;
pcm_channels = bebob->rx_stream_formations[index].pcm;
midi_channels = bebob->rx_stream_formations[index].midi;
amdtp_stream_set_parameters(&bebob->rx_stream,
rate, pcm_channels, midi_channels * 8);
err = amdtp_stream_set_parameters(&bebob->rx_stream, rate,
pcm_channels, midi_channels * 8);
if (err < 0)
goto end;
/* establish connections for both streams */
err = cmp_connection_establish(&bebob->out_conn,
......
......@@ -133,7 +133,10 @@ static int start_stream(struct snd_dice *dice, struct amdtp_stream *stream,
stream->double_pcm_frames = false;
}
amdtp_stream_set_parameters(stream, rate, pcm_chs, midi_ports);
err = amdtp_stream_set_parameters(stream, rate, pcm_chs, midi_ports);
if (err < 0)
goto end;
if (mode > 1) {
pcm_chs /= 2;
......
......@@ -73,8 +73,10 @@ start_stream(struct snd_efw *efw, struct amdtp_stream *stream,
midi_ports = efw->midi_in_ports;
}
amdtp_stream_set_parameters(stream, sampling_rate,
pcm_channels, midi_ports);
err = amdtp_stream_set_parameters(stream, sampling_rate,
pcm_channels, midi_ports);
if (err < 0)
goto end;
/* establish connection via CMP */
err = cmp_connection_establish(conn,
......
......@@ -155,7 +155,10 @@ static int start_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream,
err = -EINVAL;
goto end;
}
amdtp_stream_set_parameters(stream, rate, pcm_channels, midi_ports);
err = amdtp_stream_set_parameters(stream, rate,
pcm_channels, midi_ports);
if (err < 0)
goto end;
err = cmp_connection_establish(conn,
amdtp_stream_get_max_payload(stream));
......
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