Merge "slimbus: stream: add support to control port disconnect"

This commit is contained in:
qctecmdr 2022-10-14 13:36:41 -07:00 committed by Gerrit - the friendly Code Review server
commit b87cea8461
2 changed files with 46 additions and 0 deletions

View File

@ -449,6 +449,50 @@ int slim_stream_unprepare(struct slim_stream_runtime *stream)
}
EXPORT_SYMBOL_GPL(slim_stream_unprepare);
/**
* slim_stream_unprepare_disconnect_port() - Un-prepare and disconnect
* selected SLIMbus Stream ports
*
* @stream: instance of slim stream runtime to unprepare
* @disconnect_ports: disconnect the ports of the stream
* @is_session_completed: free the ports allocated to the stream
*
* This API will disconnect all the ports and 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_disconnect_port(struct slim_stream_runtime *stream,
bool disconnect_ports, bool is_session_completed)
{
int i;
if (!stream) {
pr_err("%s: Stream is NULL, Check from client side\n", __func__);
return -EINVAL;
}
if (!stream->ports || !stream->num_ports) {
pr_err("%s: Stream port is NULL %d\n", __func__, stream->num_ports);
return -EINVAL;
}
if (disconnect_ports) {
for (i = 0; i < stream->num_ports; i++)
slim_disconnect_port(stream, &stream->ports[i]);
}
if (is_session_completed) {
kfree(stream->ports);
stream->ports = NULL;
stream->num_ports = 0;
}
return 0;
}
EXPORT_SYMBOL(slim_stream_unprepare_disconnect_port);
/**
* slim_stream_free() - Free a SLIMbus Stream
*

View File

@ -207,6 +207,8 @@ int slim_stream_prepare(struct slim_stream_runtime *stream,
int slim_stream_enable(struct slim_stream_runtime *stream);
int slim_stream_disable(struct slim_stream_runtime *stream);
int slim_stream_unprepare(struct slim_stream_runtime *stream);
int slim_stream_unprepare_disconnect_port(struct slim_stream_runtime *stream,
bool disconnect_ports, bool is_session_completed);
int slim_stream_free(struct slim_stream_runtime *stream);
#endif /* _LINUX_SLIMBUS_H */