// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) // // This file is provided under a dual BSD/GPLv2 license. When using or // redistributing this file, you may do so under either license. // // Copyright(c) 2018 Intel Corporation // // Author: Liam Girdwood <liam.r.girdwood@linux.intel.com> // // Generic IPC layer that can work over MMIO and SPI/I2C. PHY layer provided // by platform driver code. //
/** * sof_ipc_send_msg - generic function to prepare and send one IPC message * @sdev: pointer to SOF core device struct * @msg_data: pointer to a message to send * @msg_bytes: number of bytes in the message * @reply_bytes: number of bytes available for the reply. * The buffer for the reply data is not passed to this * function, the available size is an information for the * reply handling functions. * * On success the function returns 0, otherwise negative error number. * * Note: higher level sdev->ipc->tx_mutex must be held to make sure that * transfers are synchronized.
*/ int sof_ipc_send_msg(struct snd_sof_dev *sdev, void *msg_data, size_t msg_bytes,
size_t reply_bytes)
{ struct snd_sof_ipc *ipc = sdev->ipc; struct snd_sof_ipc_msg *msg; int ret;
if (ipc->disable_ipc_tx || sdev->fw_state != SOF_FW_BOOT_COMPLETE) return -ENODEV;
/* * The spin-lock is needed to protect message objects against other * atomic contexts.
*/
spin_lock_irq(&sdev->ipc_lock);
/* IPC set or get data from host to DSP */ int sof_ipc_set_get_data(struct snd_sof_ipc *ipc, void *msg_data,
size_t msg_bytes, bool set)
{ return ipc->ops->set_get_data(ipc->sdev, msg_data, msg_bytes, set);
}
EXPORT_SYMBOL(sof_ipc_set_get_data);
/* * send IPC message from host to DSP without modifying the DSP state. * This will be used for IPC's that can be handled by the DSP * even in a low-power D0 substate.
*/ int sof_ipc_tx_message_no_pm(struct snd_sof_ipc *ipc, void *msg_data, size_t msg_bytes, void *reply_data, size_t reply_bytes)
{ if (msg_bytes > ipc->max_payload_size ||
reply_bytes > ipc->max_payload_size) return -ENOBUFS;
/* Generic helper function to retrieve the reply */ void snd_sof_ipc_get_reply(struct snd_sof_dev *sdev)
{ /* * Sometimes, there is unexpected reply ipc arriving. The reply * ipc belongs to none of the ipcs sent from driver. * In this case, the driver must ignore the ipc.
*/ if (!sdev->msg) {
dev_warn(sdev->dev, "unexpected ipc interrupt raised!\n"); return;
}
if (msg->ipc_complete) {
dev_dbg(sdev->dev, "no reply expected, received 0x%x, will be ignored",
msg_id); return;
}
/* wake up and return the error if we have waiters on this message ? */
msg->ipc_complete = true;
wake_up(&msg->waitq);
}
EXPORT_SYMBOL(snd_sof_ipc_reply);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.