Commit be4a2894 authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Takashi Iwai

ALSA: firewire-lib: Rename functions, structure, member for AMDTP

This patch renames some functions, a structure and its member to reuse them
in both AMDTP in/out stream.
Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 4b660a7f
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "packets-buffer.h" #include "packets-buffer.h"
/** /**
* enum cip_out_flags - describes details of the streaming protocol * enum cip_flags - describes details of the streaming protocol
* @CIP_NONBLOCKING: In non-blocking mode, each packet contains * @CIP_NONBLOCKING: In non-blocking mode, each packet contains
* sample_rate/8000 samples, with rounding up or down to adjust * sample_rate/8000 samples, with rounding up or down to adjust
* for clock skew and left-over fractional samples. This should * for clock skew and left-over fractional samples. This should
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* two samples of a channel are stored consecutively in the packet. * two samples of a channel are stored consecutively in the packet.
* Requires blocking mode and SYT_INTERVAL-aligned PCM buffer size. * Requires blocking mode and SYT_INTERVAL-aligned PCM buffer size.
*/ */
enum cip_out_flags { enum cip_flags {
CIP_NONBLOCKING = 0x00, CIP_NONBLOCKING = 0x00,
CIP_BLOCKING = 0x01, CIP_BLOCKING = 0x01,
CIP_HI_DUALWIRE = 0x02, CIP_HI_DUALWIRE = 0x02,
...@@ -48,9 +48,9 @@ struct fw_unit; ...@@ -48,9 +48,9 @@ struct fw_unit;
struct fw_iso_context; struct fw_iso_context;
struct snd_pcm_substream; struct snd_pcm_substream;
struct amdtp_out_stream { struct amdtp_stream {
struct fw_unit *unit; struct fw_unit *unit;
enum cip_out_flags flags; enum cip_flags flags;
struct fw_iso_context *context; struct fw_iso_context *context;
struct mutex mutex; struct mutex mutex;
...@@ -59,7 +59,7 @@ struct amdtp_out_stream { ...@@ -59,7 +59,7 @@ struct amdtp_out_stream {
unsigned int data_block_quadlets; unsigned int data_block_quadlets;
unsigned int pcm_channels; unsigned int pcm_channels;
unsigned int midi_ports; unsigned int midi_ports;
void (*transfer_samples)(struct amdtp_out_stream *s, void (*transfer_samples)(struct amdtp_stream *s,
struct snd_pcm_substream *pcm, struct snd_pcm_substream *pcm,
__be32 *buffer, unsigned int frames); __be32 *buffer, unsigned int frames);
...@@ -84,56 +84,62 @@ struct amdtp_out_stream { ...@@ -84,56 +84,62 @@ struct amdtp_out_stream {
bool pointer_flush; bool pointer_flush;
}; };
int amdtp_out_stream_init(struct amdtp_out_stream *s, struct fw_unit *unit, int amdtp_stream_init(struct amdtp_stream *s, struct fw_unit *unit,
enum cip_out_flags flags); enum cip_flags flags);
void amdtp_out_stream_destroy(struct amdtp_out_stream *s); void amdtp_stream_destroy(struct amdtp_stream *s);
void amdtp_out_stream_set_parameters(struct amdtp_out_stream *s, void amdtp_stream_set_parameters(struct amdtp_stream *s,
unsigned int rate, unsigned int rate,
unsigned int pcm_channels, unsigned int pcm_channels,
unsigned int midi_ports); unsigned int midi_ports);
unsigned int amdtp_out_stream_get_max_payload(struct amdtp_out_stream *s); unsigned int amdtp_stream_get_max_payload(struct amdtp_stream *s);
int amdtp_out_stream_start(struct amdtp_out_stream *s, int channel, int speed); int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed);
void amdtp_out_stream_update(struct amdtp_out_stream *s); void amdtp_stream_update(struct amdtp_stream *s);
void amdtp_out_stream_stop(struct amdtp_out_stream *s); void amdtp_stream_stop(struct amdtp_stream *s);
void amdtp_out_stream_set_pcm_format(struct amdtp_out_stream *s, void amdtp_stream_set_pcm_format(struct amdtp_stream *s,
snd_pcm_format_t format); snd_pcm_format_t format);
void amdtp_out_stream_pcm_prepare(struct amdtp_out_stream *s); void amdtp_stream_pcm_prepare(struct amdtp_stream *s);
unsigned long amdtp_out_stream_pcm_pointer(struct amdtp_out_stream *s); unsigned long amdtp_stream_pcm_pointer(struct amdtp_stream *s);
void amdtp_out_stream_pcm_abort(struct amdtp_out_stream *s); void amdtp_stream_pcm_abort(struct amdtp_stream *s);
extern const unsigned int amdtp_syt_intervals[CIP_SFC_COUNT]; extern const unsigned int amdtp_syt_intervals[CIP_SFC_COUNT];
static inline bool amdtp_out_stream_running(struct amdtp_out_stream *s) /**
* amdtp_stream_running - check stream is running or not
* @s: the AMDTP stream
*
* If this function returns true, the stream is running.
*/
static inline bool amdtp_stream_running(struct amdtp_stream *s)
{ {
return !IS_ERR(s->context); return !IS_ERR(s->context);
} }
/** /**
* amdtp_out_streaming_error - check for streaming error * amdtp_streaming_error - check for streaming error
* @s: the AMDTP output stream * @s: the AMDTP stream
* *
* If this function returns true, the stream's packet queue has stopped due to * If this function returns true, the stream's packet queue has stopped due to
* an asynchronous error. * an asynchronous error.
*/ */
static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s) static inline bool amdtp_streaming_error(struct amdtp_stream *s)
{ {
return s->packet_index < 0; return s->packet_index < 0;
} }
/** /**
* amdtp_out_stream_pcm_trigger - start/stop playback from a PCM device * amdtp_stream_pcm_trigger - start/stop playback from a PCM device
* @s: the AMDTP output stream * @s: the AMDTP stream
* @pcm: the PCM device to be started, or %NULL to stop the current device * @pcm: the PCM device to be started, or %NULL to stop the current device
* *
* Call this function on a running isochronous stream to enable the actual * Call this function on a running isochronous stream to enable the actual
* transmission of PCM data. This function should be called from the PCM * transmission of PCM data. This function should be called from the PCM
* device's .trigger callback. * device's .trigger callback.
*/ */
static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s, static inline void amdtp_stream_pcm_trigger(struct amdtp_stream *s,
struct snd_pcm_substream *pcm) struct snd_pcm_substream *pcm)
{ {
ACCESS_ONCE(s->pcm) = pcm; ACCESS_ONCE(s->pcm) = pcm;
} }
......
...@@ -51,7 +51,7 @@ struct dice { ...@@ -51,7 +51,7 @@ struct dice {
wait_queue_head_t hwdep_wait; wait_queue_head_t hwdep_wait;
u32 notification_bits; u32 notification_bits;
struct fw_iso_resources resources; struct fw_iso_resources resources;
struct amdtp_out_stream stream; struct amdtp_stream stream;
}; };
MODULE_DESCRIPTION("DICE driver"); MODULE_DESCRIPTION("DICE driver");
...@@ -460,17 +460,17 @@ static int dice_stream_start_packets(struct dice *dice) ...@@ -460,17 +460,17 @@ static int dice_stream_start_packets(struct dice *dice)
{ {
int err; int err;
if (amdtp_out_stream_running(&dice->stream)) if (amdtp_stream_running(&dice->stream))
return 0; return 0;
err = amdtp_out_stream_start(&dice->stream, dice->resources.channel, err = amdtp_stream_start(&dice->stream, dice->resources.channel,
fw_parent_device(dice->unit)->max_speed); fw_parent_device(dice->unit)->max_speed);
if (err < 0) if (err < 0)
return err; return err;
err = dice_enable_set(dice); err = dice_enable_set(dice);
if (err < 0) { if (err < 0) {
amdtp_out_stream_stop(&dice->stream); amdtp_stream_stop(&dice->stream);
return err; return err;
} }
...@@ -484,7 +484,7 @@ static int dice_stream_start(struct dice *dice) ...@@ -484,7 +484,7 @@ static int dice_stream_start(struct dice *dice)
if (!dice->resources.allocated) { if (!dice->resources.allocated) {
err = fw_iso_resources_allocate(&dice->resources, err = fw_iso_resources_allocate(&dice->resources,
amdtp_out_stream_get_max_payload(&dice->stream), amdtp_stream_get_max_payload(&dice->stream),
fw_parent_device(dice->unit)->max_speed); fw_parent_device(dice->unit)->max_speed);
if (err < 0) if (err < 0)
goto error; goto error;
...@@ -516,9 +516,9 @@ static int dice_stream_start(struct dice *dice) ...@@ -516,9 +516,9 @@ static int dice_stream_start(struct dice *dice)
static void dice_stream_stop_packets(struct dice *dice) static void dice_stream_stop_packets(struct dice *dice)
{ {
if (amdtp_out_stream_running(&dice->stream)) { if (amdtp_stream_running(&dice->stream)) {
dice_enable_clear(dice); dice_enable_clear(dice);
amdtp_out_stream_stop(&dice->stream); amdtp_stream_stop(&dice->stream);
} }
} }
...@@ -581,12 +581,12 @@ static int dice_hw_params(struct snd_pcm_substream *substream, ...@@ -581,12 +581,12 @@ static int dice_hw_params(struct snd_pcm_substream *substream,
return err; return err;
mode = rate_index_to_mode(rate_index); mode = rate_index_to_mode(rate_index);
amdtp_out_stream_set_parameters(&dice->stream, amdtp_stream_set_parameters(&dice->stream,
params_rate(hw_params), params_rate(hw_params),
params_channels(hw_params), params_channels(hw_params),
dice->rx_midi_ports[mode]); dice->rx_midi_ports[mode]);
amdtp_out_stream_set_pcm_format(&dice->stream, amdtp_stream_set_pcm_format(&dice->stream,
params_format(hw_params)); params_format(hw_params));
return 0; return 0;
} }
...@@ -609,7 +609,7 @@ static int dice_prepare(struct snd_pcm_substream *substream) ...@@ -609,7 +609,7 @@ static int dice_prepare(struct snd_pcm_substream *substream)
mutex_lock(&dice->mutex); mutex_lock(&dice->mutex);
if (amdtp_out_streaming_error(&dice->stream)) if (amdtp_streaming_error(&dice->stream))
dice_stream_stop_packets(dice); dice_stream_stop_packets(dice);
err = dice_stream_start(dice); err = dice_stream_start(dice);
...@@ -620,7 +620,7 @@ static int dice_prepare(struct snd_pcm_substream *substream) ...@@ -620,7 +620,7 @@ static int dice_prepare(struct snd_pcm_substream *substream)
mutex_unlock(&dice->mutex); mutex_unlock(&dice->mutex);
amdtp_out_stream_pcm_prepare(&dice->stream); amdtp_stream_pcm_prepare(&dice->stream);
return 0; return 0;
} }
...@@ -640,7 +640,7 @@ static int dice_trigger(struct snd_pcm_substream *substream, int cmd) ...@@ -640,7 +640,7 @@ static int dice_trigger(struct snd_pcm_substream *substream, int cmd)
default: default:
return -EINVAL; return -EINVAL;
} }
amdtp_out_stream_pcm_trigger(&dice->stream, pcm); amdtp_stream_pcm_trigger(&dice->stream, pcm);
return 0; return 0;
} }
...@@ -649,7 +649,7 @@ static snd_pcm_uframes_t dice_pointer(struct snd_pcm_substream *substream) ...@@ -649,7 +649,7 @@ static snd_pcm_uframes_t dice_pointer(struct snd_pcm_substream *substream)
{ {
struct dice *dice = substream->private_data; struct dice *dice = substream->private_data;
return amdtp_out_stream_pcm_pointer(&dice->stream); return amdtp_stream_pcm_pointer(&dice->stream);
} }
static int dice_create_pcm(struct dice *dice) static int dice_create_pcm(struct dice *dice)
...@@ -1104,7 +1104,7 @@ static void dice_card_free(struct snd_card *card) ...@@ -1104,7 +1104,7 @@ static void dice_card_free(struct snd_card *card)
{ {
struct dice *dice = card->private_data; struct dice *dice = card->private_data;
amdtp_out_stream_destroy(&dice->stream); amdtp_stream_destroy(&dice->stream);
fw_core_remove_address_handler(&dice->notification_handler); fw_core_remove_address_handler(&dice->notification_handler);
mutex_destroy(&dice->mutex); mutex_destroy(&dice->mutex);
} }
...@@ -1360,8 +1360,8 @@ static int dice_probe(struct fw_unit *unit, const struct ieee1394_device_id *id) ...@@ -1360,8 +1360,8 @@ static int dice_probe(struct fw_unit *unit, const struct ieee1394_device_id *id)
goto err_owner; goto err_owner;
dice->resources.channels_mask = 0x00000000ffffffffuLL; dice->resources.channels_mask = 0x00000000ffffffffuLL;
err = amdtp_out_stream_init(&dice->stream, unit, err = amdtp_stream_init(&dice->stream, unit,
CIP_BLOCKING | CIP_HI_DUALWIRE); CIP_BLOCKING | CIP_HI_DUALWIRE);
if (err < 0) if (err < 0)
goto err_resources; goto err_resources;
...@@ -1417,7 +1417,7 @@ static void dice_remove(struct fw_unit *unit) ...@@ -1417,7 +1417,7 @@ static void dice_remove(struct fw_unit *unit)
{ {
struct dice *dice = dev_get_drvdata(&unit->device); struct dice *dice = dev_get_drvdata(&unit->device);
amdtp_out_stream_pcm_abort(&dice->stream); amdtp_stream_pcm_abort(&dice->stream);
snd_card_disconnect(dice->card); snd_card_disconnect(dice->card);
...@@ -1443,7 +1443,7 @@ static void dice_bus_reset(struct fw_unit *unit) ...@@ -1443,7 +1443,7 @@ static void dice_bus_reset(struct fw_unit *unit)
* to stop so that the application can restart them in an orderly * to stop so that the application can restart them in an orderly
* manner. * manner.
*/ */
amdtp_out_stream_pcm_abort(&dice->stream); amdtp_stream_pcm_abort(&dice->stream);
mutex_lock(&dice->mutex); mutex_lock(&dice->mutex);
......
...@@ -51,7 +51,7 @@ struct fwspk { ...@@ -51,7 +51,7 @@ struct fwspk {
const struct device_info *device_info; const struct device_info *device_info;
struct mutex mutex; struct mutex mutex;
struct cmp_connection connection; struct cmp_connection connection;
struct amdtp_out_stream stream; struct amdtp_stream stream;
bool mute; bool mute;
s16 volume[6]; s16 volume[6];
s16 volume_min; s16 volume_min;
...@@ -187,8 +187,8 @@ static int fwspk_close(struct snd_pcm_substream *substream) ...@@ -187,8 +187,8 @@ static int fwspk_close(struct snd_pcm_substream *substream)
static void fwspk_stop_stream(struct fwspk *fwspk) static void fwspk_stop_stream(struct fwspk *fwspk)
{ {
if (amdtp_out_stream_running(&fwspk->stream)) { if (amdtp_stream_running(&fwspk->stream)) {
amdtp_out_stream_stop(&fwspk->stream); amdtp_stream_stop(&fwspk->stream);
cmp_connection_break(&fwspk->connection); cmp_connection_break(&fwspk->connection);
} }
} }
...@@ -244,13 +244,13 @@ static int fwspk_hw_params(struct snd_pcm_substream *substream, ...@@ -244,13 +244,13 @@ static int fwspk_hw_params(struct snd_pcm_substream *substream,
if (err < 0) if (err < 0)
goto error; goto error;
amdtp_out_stream_set_parameters(&fwspk->stream, amdtp_stream_set_parameters(&fwspk->stream,
params_rate(hw_params), params_rate(hw_params),
params_channels(hw_params), params_channels(hw_params),
0); 0);
amdtp_out_stream_set_pcm_format(&fwspk->stream, amdtp_stream_set_pcm_format(&fwspk->stream,
params_format(hw_params)); params_format(hw_params));
err = fwspk_set_rate(fwspk, fwspk->stream.sfc); err = fwspk_set_rate(fwspk, fwspk->stream.sfc);
if (err < 0) if (err < 0)
...@@ -282,25 +282,25 @@ static int fwspk_prepare(struct snd_pcm_substream *substream) ...@@ -282,25 +282,25 @@ static int fwspk_prepare(struct snd_pcm_substream *substream)
mutex_lock(&fwspk->mutex); mutex_lock(&fwspk->mutex);
if (amdtp_out_streaming_error(&fwspk->stream)) if (amdtp_streaming_error(&fwspk->stream))
fwspk_stop_stream(fwspk); fwspk_stop_stream(fwspk);
if (!amdtp_out_stream_running(&fwspk->stream)) { if (!amdtp_stream_running(&fwspk->stream)) {
err = cmp_connection_establish(&fwspk->connection, err = cmp_connection_establish(&fwspk->connection,
amdtp_out_stream_get_max_payload(&fwspk->stream)); amdtp_stream_get_max_payload(&fwspk->stream));
if (err < 0) if (err < 0)
goto err_mutex; goto err_mutex;
err = amdtp_out_stream_start(&fwspk->stream, err = amdtp_stream_start(&fwspk->stream,
fwspk->connection.resources.channel, fwspk->connection.resources.channel,
fwspk->connection.speed); fwspk->connection.speed);
if (err < 0) if (err < 0)
goto err_connection; goto err_connection;
} }
mutex_unlock(&fwspk->mutex); mutex_unlock(&fwspk->mutex);
amdtp_out_stream_pcm_prepare(&fwspk->stream); amdtp_stream_pcm_prepare(&fwspk->stream);
return 0; return 0;
...@@ -327,7 +327,7 @@ static int fwspk_trigger(struct snd_pcm_substream *substream, int cmd) ...@@ -327,7 +327,7 @@ static int fwspk_trigger(struct snd_pcm_substream *substream, int cmd)
default: default:
return -EINVAL; return -EINVAL;
} }
amdtp_out_stream_pcm_trigger(&fwspk->stream, pcm); amdtp_stream_pcm_trigger(&fwspk->stream, pcm);
return 0; return 0;
} }
...@@ -335,7 +335,7 @@ static snd_pcm_uframes_t fwspk_pointer(struct snd_pcm_substream *substream) ...@@ -335,7 +335,7 @@ static snd_pcm_uframes_t fwspk_pointer(struct snd_pcm_substream *substream)
{ {
struct fwspk *fwspk = substream->private_data; struct fwspk *fwspk = substream->private_data;
return amdtp_out_stream_pcm_pointer(&fwspk->stream); return amdtp_stream_pcm_pointer(&fwspk->stream);
} }
static int fwspk_create_pcm(struct fwspk *fwspk) static int fwspk_create_pcm(struct fwspk *fwspk)
...@@ -653,7 +653,7 @@ static void fwspk_card_free(struct snd_card *card) ...@@ -653,7 +653,7 @@ static void fwspk_card_free(struct snd_card *card)
{ {
struct fwspk *fwspk = card->private_data; struct fwspk *fwspk = card->private_data;
amdtp_out_stream_destroy(&fwspk->stream); amdtp_stream_destroy(&fwspk->stream);
cmp_connection_destroy(&fwspk->connection); cmp_connection_destroy(&fwspk->connection);
fw_unit_put(fwspk->unit); fw_unit_put(fwspk->unit);
mutex_destroy(&fwspk->mutex); mutex_destroy(&fwspk->mutex);
...@@ -683,7 +683,7 @@ static int fwspk_probe(struct fw_unit *unit, ...@@ -683,7 +683,7 @@ static int fwspk_probe(struct fw_unit *unit,
if (err < 0) if (err < 0)
goto err_unit; goto err_unit;
err = amdtp_out_stream_init(&fwspk->stream, unit, CIP_NONBLOCKING); err = amdtp_stream_init(&fwspk->stream, unit, CIP_NONBLOCKING);
if (err < 0) if (err < 0)
goto err_connection; goto err_connection;
...@@ -733,21 +733,21 @@ static void fwspk_bus_reset(struct fw_unit *unit) ...@@ -733,21 +733,21 @@ static void fwspk_bus_reset(struct fw_unit *unit)
fcp_bus_reset(fwspk->unit); fcp_bus_reset(fwspk->unit);
if (cmp_connection_update(&fwspk->connection) < 0) { if (cmp_connection_update(&fwspk->connection) < 0) {
amdtp_out_stream_pcm_abort(&fwspk->stream); amdtp_stream_pcm_abort(&fwspk->stream);
mutex_lock(&fwspk->mutex); mutex_lock(&fwspk->mutex);
fwspk_stop_stream(fwspk); fwspk_stop_stream(fwspk);
mutex_unlock(&fwspk->mutex); mutex_unlock(&fwspk->mutex);
return; return;
} }
amdtp_out_stream_update(&fwspk->stream); amdtp_stream_update(&fwspk->stream);
} }
static void fwspk_remove(struct fw_unit *unit) static void fwspk_remove(struct fw_unit *unit)
{ {
struct fwspk *fwspk = dev_get_drvdata(&unit->device); struct fwspk *fwspk = dev_get_drvdata(&unit->device);
amdtp_out_stream_pcm_abort(&fwspk->stream); amdtp_stream_pcm_abort(&fwspk->stream);
snd_card_disconnect(fwspk->card); snd_card_disconnect(fwspk->card);
mutex_lock(&fwspk->mutex); mutex_lock(&fwspk->mutex);
......
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