ALSA: hda: document state machine for hdac_streams
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Mon, 19 Sep 2022 12:10:35 +0000 (14:10 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 20 Sep 2022 06:08:13 +0000 (08:08 +0200)
The code in this library is far from self-explanatory, hopefully this
state diagram reverse-engineered from the code will help others
understand the expected transitions.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20220919121041.43463-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/hda/hdac_stream.c

index 2dbde3d..2e98f5f 100644 (file)
 #include <sound/hda_register.h>
 #include "trace.h"
 
+/*
+ * the hdac_stream library is intended to be used with the following
+ * transitions. The states are not formally defined in the code but loosely
+ * inspired by boolean variables. Note that the 'prepared' field is not used
+ * in this library but by the callers during the hw_params/prepare transitions
+ *
+ *                        |
+ *     stream_init()      |
+ *                        v
+ *                     +--+-------+
+ *                     |  unused  |
+ *                     +--+----+--+
+ *                        |    ^
+ *     stream_assign()    |    |    stream_release()
+ *                        v    |
+ *                     +--+----+--+
+ *                     |  opened  |
+ *                     +--+----+--+
+ *                        |    ^
+ *     stream_reset()     |    |
+ *     stream_setup()     |    |    stream_cleanup()
+ *                        v    |
+ *                     +--+----+--+
+ *                     | prepared |
+ *                     +--+----+--+
+ *                        |    ^
+ *     stream_start()     |    |    stream_stop()
+ *                        v    |
+ *                     +--+----+--+
+ *                     |  running |
+ *                     +----------+
+ */
+
 /**
  * snd_hdac_get_stream_stripe_ctl - get stripe control value
  * @bus: HD-audio core bus