public inbox for alsa-devel@alsa-project.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: alsa-devel@alsa-project.org, andriy.shevchenko@intel.com,
	Daniel Baluta <daniel.baluta@gmail.com>,
	liam.r.girdwood@linux.intel.com, vkoul@kernel.org,
	broonie@kernel.org, Alan Cox <alan@linux.intel.com>,
	sound-open-firmware@alsa-project.org
Subject: Re: [PATCH v3 04/14] ASoC: SOF: Add support for IPC IO between DSP and Host
Date: Wed, 12 Dec 2018 09:17:55 +0100	[thread overview]
Message-ID: <s5hbm5rupjg.wl-tiwai@suse.de> (raw)
In-Reply-To: <20181211212318.28644-5-pierre-louis.bossart@linux.intel.com>

On Tue, 11 Dec 2018 22:23:08 +0100,
Pierre-Louis Bossart wrote:
> 
> From: Liam Girdwood <liam.r.girdwood@linux.intel.com>
> 
> Define an IPC ABI for all host <--> DSP communication. This ABI should
> be transport agnostic. i.e. it should work on MMIO and SPI/I2C style
> interfaces.
> 
> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> ---
>  include/sound/sof/control.h   | 125 ++++++
>  include/sound/sof/dai-intel.h | 175 ++++++++
>  include/sound/sof/dai.h       |  75 ++++
>  include/sound/sof/header.h    | 158 +++++++
>  include/sound/sof/info.h      | 118 +++++
>  include/sound/sof/pm.h        |  48 ++
>  include/sound/sof/stream.h    | 149 +++++++
>  include/sound/sof/trace.h     |  66 +++
>  sound/soc/sof/ipc.c           | 813 ++++++++++++++++++++++++++++++++++
>  9 files changed, 1727 insertions(+)
>  create mode 100644 include/sound/sof/control.h
>  create mode 100644 include/sound/sof/dai-intel.h
>  create mode 100644 include/sound/sof/dai.h
>  create mode 100644 include/sound/sof/header.h
>  create mode 100644 include/sound/sof/info.h
>  create mode 100644 include/sound/sof/pm.h
>  create mode 100644 include/sound/sof/stream.h
>  create mode 100644 include/sound/sof/trace.h
>  create mode 100644 sound/soc/sof/ipc.c
> 
> diff --git a/include/sound/sof/control.h b/include/sound/sof/control.h
> new file mode 100644
> index 000000000000..7d7d2eba7d76
> --- /dev/null
> +++ b/include/sound/sof/control.h
> @@ -0,0 +1,125 @@
> +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) 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. All rights reserved.
> + */
> +
> +#ifndef __INCLUDE_SOUND_SOF_CONTROL_H__
> +#define __INCLUDE_SOUND_SOF_CONTROL_H__
> +
> +#include <uapi/sound/sof/header.h>
> +#include <sound/sof/header.h>
> +
> +/*
> + * Component Mixers and Controls
> + */
> +
> +/* channel positions - uses same values as ALSA */
> +enum sof_ipc_chmap {
> +	SOF_CHMAP_UNKNOWN = 0,
> +	SOF_CHMAP_NA,		/**< N/A, silent */
> +	SOF_CHMAP_MONO,		/**< mono stream */
> +	SOF_CHMAP_FL,		/**< front left */
> +	SOF_CHMAP_FR,		/**< front right */
> +	SOF_CHMAP_RL,		/**< rear left */
> +	SOF_CHMAP_RR,		/**< rear right */
> +	SOF_CHMAP_FC,		/**< front centre */
> +	SOF_CHMAP_LFE,		/**< LFE */
> +	SOF_CHMAP_SL,		/**< side left */
> +	SOF_CHMAP_SR,		/**< side right */
> +	SOF_CHMAP_RC,		/**< rear centre */
> +	SOF_CHMAP_FLC,		/**< front left centre */
> +	SOF_CHMAP_FRC,		/**< front right centre */
> +	SOF_CHMAP_RLC,		/**< rear left centre */
> +	SOF_CHMAP_RRC,		/**< rear right centre */
> +	SOF_CHMAP_FLW,		/**< front left wide */
> +	SOF_CHMAP_FRW,		/**< front right wide */
> +	SOF_CHMAP_FLH,		/**< front left high */
> +	SOF_CHMAP_FCH,		/**< front centre high */
> +	SOF_CHMAP_FRH,		/**< front right high */
> +	SOF_CHMAP_TC,		/**< top centre */
> +	SOF_CHMAP_TFL,		/**< top front left */
> +	SOF_CHMAP_TFR,		/**< top front right */
> +	SOF_CHMAP_TFC,		/**< top front centre */
> +	SOF_CHMAP_TRL,		/**< top rear left */
> +	SOF_CHMAP_TRR,		/**< top rear right */
> +	SOF_CHMAP_TRC,		/**< top rear centre */
> +	SOF_CHMAP_TFLC,		/**< top front left centre */
> +	SOF_CHMAP_TFRC,		/**< top front right centre */
> +	SOF_CHMAP_TSL,		/**< top side left */
> +	SOF_CHMAP_TSR,		/**< top side right */
> +	SOF_CHMAP_LLFE,		/**< left LFE */
> +	SOF_CHMAP_RLFE,		/**< right LFE */
> +	SOF_CHMAP_BC,		/**< bottom centre */
> +	SOF_CHMAP_BLC,		/**< bottom left centre */
> +	SOF_CHMAP_BRC,		/**< bottom right centre */
> +	SOF_CHMAP_LAST = SOF_CHMAP_BRC,
> +};
> +
> +/* control data type and direction */
> +enum sof_ipc_ctrl_type {
> +	/*  per channel data - uses struct sof_ipc_ctrl_value_chan */
> +	SOF_CTRL_TYPE_VALUE_CHAN_GET = 0,
> +	SOF_CTRL_TYPE_VALUE_CHAN_SET,
> +	/* component data - uses struct sof_ipc_ctrl_value_comp */
> +	SOF_CTRL_TYPE_VALUE_COMP_GET,
> +	SOF_CTRL_TYPE_VALUE_COMP_SET,
> +	/* bespoke data - struct struct sof_abi_hdr */
> +	SOF_CTRL_TYPE_DATA_GET,
> +	SOF_CTRL_TYPE_DATA_SET,
> +};
> +
> +/* control command type */
> +enum sof_ipc_ctrl_cmd {
> +	SOF_CTRL_CMD_VOLUME = 0, /**< maps to ALSA volume style controls */
> +	SOF_CTRL_CMD_ENUM,	/**< maps to ALSA enum style controls */
> +	SOF_CTRL_CMD_SWITCH,	/**< maps to ALSA switch style controls */
> +	SOF_CTRL_CMD_BINARY,	/**< maps to ALSA binary style controls */
> +};
> +
> +/* generic channel mapped value data */
> +struct sof_ipc_ctrl_value_chan {
> +	uint32_t channel;	/**< channel map - enum sof_ipc_chmap */
> +	uint32_t value;

Any reason to avoid s32 and u32?
If this is supposed to be shared with user-space (or user-space may
use this as a reference of data struct), we should consider placing in
uapi directory, too.


> +/* wait for IPC message reply */
> +static int tx_wait_done(struct snd_sof_ipc *ipc, struct snd_sof_ipc_msg *msg,
> +			void *reply_data)
> +{
> +	struct snd_sof_dev *sdev = ipc->sdev;
> +	struct sof_ipc_cmd_hdr *hdr = (struct sof_ipc_cmd_hdr *)msg->msg_data;
> +	unsigned long flags;
> +	int ret;
> +
> +	/* wait for DSP IPC completion */
> +	ret = wait_event_timeout(msg->waitq, msg->ipc_complete,
> +				 msecs_to_jiffies(IPC_TIMEOUT_MSECS));
> +
> +	spin_lock_irqsave(&sdev->ipc_lock, flags);

Since this must be a sleepable context, you can safely use
spin_lock_irq() here.

> +/* send IPC message from host to DSP */
> +int sof_ipc_tx_message(struct snd_sof_ipc *ipc, u32 header,
> +		       void *msg_data, size_t msg_bytes, void *reply_data,
> +		       size_t reply_bytes)
> +{
> +	struct snd_sof_dev *sdev = ipc->sdev;
> +	struct snd_sof_ipc_msg *msg;
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&sdev->ipc_lock, flags);

Ditto.  This one calls tx_wait_done() later.

It's better to define more strictly which one can be called from the
spinlocked context and which not.


> +void snd_sof_ipc_free(struct snd_sof_dev *sdev)
> +{
> +	cancel_work_sync(&sdev->ipc->tx_kwork);
> +	cancel_work_sync(&sdev->ipc->rx_kwork);
> +}
> +EXPORT_SYMBOL(snd_sof_ipc_free);

Not specific to this function but a general question:
why not EXPORT_SYMBOL_GPL() in general in the whole SOF codes?


thanks,

Takashi

  parent reply	other threads:[~2018-12-12  8:17 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-11 21:23 [PATCH v3 00/14] Sound Open Firmware (SOF) core Pierre-Louis Bossart
2018-12-11 21:23 ` [PATCH v3 01/14] ASoC: SOF: Add Sound Open Firmware driver core Pierre-Louis Bossart
2018-12-11 22:20   ` Andy Shevchenko
2018-12-11 23:20     ` Pierre-Louis Bossart
2018-12-12  7:51   ` Takashi Iwai
2018-12-12 14:53     ` Pierre-Louis Bossart
2018-12-12 20:42   ` Daniel Baluta
2018-12-12 22:35     ` Pierre-Louis Bossart
2019-01-29 16:49   ` Daniel Baluta
2019-01-30 16:12     ` Pierre-Louis Bossart
2018-12-11 21:23 ` [PATCH v3 02/14] ASoC: SOF: Add Sound Open Firmware KControl support Pierre-Louis Bossart
2018-12-11 22:23   ` Andy Shevchenko
2018-12-11 22:48     ` Pierre-Louis Bossart
2018-12-11 23:25       ` Andy Shevchenko
2018-12-12 20:18     ` Pierre-Louis Bossart
2018-12-12  7:35   ` Takashi Iwai
2018-12-12 15:01     ` Pierre-Louis Bossart
2018-12-11 21:23 ` [PATCH v3 03/14] ASoC: SOF: Add driver debug support Pierre-Louis Bossart
2018-12-11 22:32   ` Andy Shevchenko
2018-12-11 23:29     ` Pierre-Louis Bossart
2019-01-09 19:40   ` Mark Brown
2019-01-10 20:47     ` Pierre-Louis Bossart
2018-12-11 21:23 ` [PATCH v3 04/14] ASoC: SOF: Add support for IPC IO between DSP and Host Pierre-Louis Bossart
2018-12-11 22:57   ` Andy Shevchenko
2018-12-11 23:38     ` Pierre-Louis Bossart
2018-12-12  8:17   ` Takashi Iwai [this message]
2018-12-12 15:19     ` Pierre-Louis Bossart
2018-12-12 15:34       ` Takashi Iwai
2018-12-13  5:24       ` Keyon Jie
2018-12-13  7:48         ` Takashi Iwai
2018-12-13  9:13           ` Keyon Jie
2018-12-13  8:06         ` Keyon Jie
2018-12-13  8:59           ` rander.wang
2019-01-09 20:37   ` Mark Brown
2019-01-10 20:11     ` Pierre-Louis Bossart
2019-01-22 19:04       ` Mark Brown
2019-01-22 21:05         ` Pierre-Louis Bossart
2019-01-22 21:13           ` Mark Brown
2019-01-23  5:51           ` [Sound-open-firmware] " Keyon Jie
2019-01-14 15:10   ` Daniel Baluta
2019-01-14 17:39     ` Pierre-Louis Bossart
2018-12-11 21:23 ` [PATCH v3 05/14] ASoC: SOF: Add PCM operations support Pierre-Louis Bossart
2018-12-12  8:04   ` Takashi Iwai
2018-12-12 13:12     ` Andy Shevchenko
2018-12-12 15:29     ` [Sound-open-firmware] " Pierre-Louis Bossart
2018-12-12 15:43       ` Takashi Iwai
2018-12-12 16:10         ` Pierre-Louis Bossart
2018-12-12 22:09   ` Daniel Baluta
2018-12-11 21:23 ` [PATCH v3 06/14] ASoC: SOF: Add support for loading topologies Pierre-Louis Bossart
2018-12-11 21:23 ` [PATCH v3 07/14] ASoC: SOF: Add DSP firmware logger support Pierre-Louis Bossart
2018-12-11 23:21   ` Andy Shevchenko
2018-12-11 23:43     ` Pierre-Louis Bossart
2018-12-12  6:44       ` Takashi Iwai
2018-12-12 11:11   ` Takashi Iwai
2018-12-12 16:04     ` [Sound-open-firmware] " Pierre-Louis Bossart
2018-12-12 16:12       ` Takashi Iwai
2018-12-12 17:01         ` Pierre-Louis Bossart
2019-01-09 20:44   ` Mark Brown
2019-01-09 21:39     ` Pierre-Louis Bossart
2019-01-22 18:57       ` Mark Brown
2019-01-22 20:33         ` Pierre-Louis Bossart
2019-01-22 20:41           ` Mark Brown
2019-01-22 20:52             ` Pierre-Louis Bossart
2019-01-22 21:08               ` Mark Brown
2019-01-22 21:13                 ` Pierre-Louis Bossart
2018-12-11 21:23 ` [PATCH v3 08/14] ASoC: SOF: Add DSP HW abstraction operations Pierre-Louis Bossart
2018-12-11 23:16   ` Andy Shevchenko
2018-12-11 23:45     ` Pierre-Louis Bossart
2019-01-09 20:51   ` Mark Brown
2019-01-09 21:37     ` Pierre-Louis Bossart
2019-01-22 18:56       ` Mark Brown
2018-12-11 21:23 ` [PATCH v3 09/14] ASoC: SOF: Add firmware loader support Pierre-Louis Bossart
2018-12-11 22:38   ` Andy Shevchenko
2018-12-11 23:54     ` Pierre-Louis Bossart
2019-01-09 20:55       ` Mark Brown
2018-12-12 11:23   ` Takashi Iwai
2018-12-12 16:06     ` [Sound-open-firmware] " Pierre-Louis Bossart
2019-01-09 21:02   ` Mark Brown
2019-01-09 21:24     ` Pierre-Louis Bossart
2018-12-11 21:23 ` [PATCH v3 10/14] ASoC: SOF: Add userspace ABI support Pierre-Louis Bossart
2018-12-21 11:10   ` Daniel Baluta
2018-12-21 14:59     ` [Sound-open-firmware] " Pierre-Louis Bossart
2018-12-11 21:23 ` [PATCH v3 11/14] ASoC: SOF: Add PM support Pierre-Louis Bossart
2018-12-12 11:32   ` Takashi Iwai
2018-12-12 16:08     ` Pierre-Louis Bossart
2018-12-11 21:23 ` [PATCH v3 12/14] ASoC: SOF: Add Nocodec machine driver support Pierre-Louis Bossart
2018-12-11 21:23 ` [PATCH v3 13/14] ASoC: SOF: Add xtensa support Pierre-Louis Bossart
2018-12-11 23:08   ` Andy Shevchenko
2018-12-12  0:00     ` Pierre-Louis Bossart
     [not found]       ` <93aff9af-c693-c951-4821-e9e334133ed0@linux.intel.com>
2018-12-13  9:58         ` [Sound-open-firmware] " rander.wang
2018-12-17 13:45           ` Takashi Iwai
2018-12-17 14:24             ` Mark Brown
2018-12-11 21:23 ` [PATCH v3 14/14] ASoC: SOF: Add utils Pierre-Louis Bossart
2018-12-11 23:06   ` Andy Shevchenko
2018-12-12  0:06     ` Pierre-Louis Bossart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hbm5rupjg.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alan@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@gmail.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=sound-open-firmware@alsa-project.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox