// SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2018, Linaro Limited #include <linux/kernel.h> #include <linux/errno.h> #include <linux/slab.h> #include <linux/list.h> #include <linux/slimbus.h> #include <uapi/sound/asound.h> #include "slimbus.h" /** * struct segdist_code - Segment Distributions code from * Table 20 of SLIMbus Specs Version 2.0 * * @ratem: Channel Rate Multipler(Segments per Superframe) * @seg_interval: Number of slots between the first Slot of Segment * and the first slot of the next consecutive Segment. * @segdist_code: Segment Distribution Code SD[11:0] * @seg_offset_mask: Segment offset mask in SD[11:0] */ struct segdist_code { … }; /* segdist_codes - List of all possible Segment Distribution codes. */ static const struct segdist_code segdist_codes[] = …; /* * Presence Rate table for all Natural Frequencies * The Presence rate of a constant bitrate stream is mean flow rate of the * stream expressed in occupied Segments of that Data Channel per second. * Table 66 from SLIMbus 2.0 Specs * * Index of the table corresponds to Presence rate code for the respective rate * in the table. */ static const int slim_presence_rate_table[] = …; /** * slim_stream_allocate() - Allocate a new SLIMbus Stream * @dev:Slim device to be associated with * @name: name of the stream * * This is very first call for SLIMbus streaming, this API will allocate * a new SLIMbus stream and return a valid stream runtime pointer for client * to use it in subsequent stream apis. state of stream is set to ALLOCATED * * Return: valid pointer on success and error code on failure. * From ASoC DPCM framework, this state is linked to startup() operation. */ struct slim_stream_runtime *slim_stream_allocate(struct slim_device *dev, const char *name) { … } EXPORT_SYMBOL_GPL(…); static int slim_connect_port_channel(struct slim_stream_runtime *stream, struct slim_port *port) { … } static int slim_disconnect_port(struct slim_stream_runtime *stream, struct slim_port *port) { … } static int slim_deactivate_remove_channel(struct slim_stream_runtime *stream, struct slim_port *port) { … } static int slim_get_prate_code(int rate) { … } /** * slim_stream_prepare() - Prepare a SLIMbus Stream * * @rt: instance of slim stream runtime to configure * @cfg: new configuration for the stream * * This API will configure SLIMbus stream with config parameters from cfg. * return zero on success and error code on failure. From ASoC DPCM framework, * this state is linked to hw_params() operation. */ int slim_stream_prepare(struct slim_stream_runtime *rt, struct slim_stream_config *cfg) { … } EXPORT_SYMBOL_GPL(…); static int slim_define_channel_content(struct slim_stream_runtime *stream, struct slim_port *port) { … } static int slim_get_segdist_code(int ratem) { … } static int slim_define_channel(struct slim_stream_runtime *stream, struct slim_port *port) { … } static int slim_activate_channel(struct slim_stream_runtime *stream, struct slim_port *port) { … } /** * slim_stream_enable() - Enable a prepared SLIMbus Stream * * @stream: instance of slim stream runtime to enable * * This API will enable all the ports and channels associated with * SLIMbus stream * * Return: zero on success and error code on failure. From ASoC DPCM framework, * this state is linked to trigger() start operation. */ int slim_stream_enable(struct slim_stream_runtime *stream) { … } EXPORT_SYMBOL_GPL(…); /** * slim_stream_disable() - Disable a SLIMbus Stream * * @stream: instance of slim stream runtime to disable * * This API will disable all the ports and channels associated with * SLIMbus stream * * Return: zero on success and error code on failure. From ASoC DPCM framework, * this state is linked to trigger() pause operation. */ int slim_stream_disable(struct slim_stream_runtime *stream) { … } EXPORT_SYMBOL_GPL(…); /** * slim_stream_unprepare() - Un-prepare a SLIMbus Stream * * @stream: instance of slim stream runtime to unprepare * * This API will un allocate all the ports and channels associated with * SLIMbus stream * * Return: zero on success and error code on failure. From ASoC DPCM framework, * this state is linked to trigger() stop operation. */ int slim_stream_unprepare(struct slim_stream_runtime *stream) { … } EXPORT_SYMBOL_GPL(…); /** * slim_stream_free() - Free a SLIMbus Stream * * @stream: instance of slim stream runtime to free * * This API will un allocate all the memory associated with * slim stream runtime, user is not allowed to make an dereference * to stream after this call. * * Return: zero on success and error code on failure. From ASoC DPCM framework, * this state is linked to shutdown() operation. */ int slim_stream_free(struct slim_stream_runtime *stream) { … } EXPORT_SYMBOL_GPL(…);