Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge from thesofproject #1

Merged
merged 22 commits into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
aa9b276
ASoC: dapm: fix kcontrols for effect widgets
singalsu Sep 6, 2018
fcb87ed
SOF: Increase DSP maximum IPC size to 384
singalsu Sep 6, 2018
f0cc5ea
SOF: Update EQ IPC header file
singalsu Sep 6, 2018
7cf3630
SOF Topology: Add ext bytes put and get feature
singalsu Sep 6, 2018
c9d77b1
SOF: fix compilation and a superfluous IRQ release
lyakh Sep 6, 2018
0f9af23
sof: add a check for the IRQ GPIO level
lyakh Sep 6, 2018
9f93a3a
rpi: temporarily disable SOF DT
lyakh Sep 6, 2018
2170a56
Revert "sof: fix compilation on non X86 platforms"
lyakh Sep 7, 2018
66dc735
sound: snd_sgbuf_aligned_pages() doesn't need CONFIG_SND_DMA_SGBUF
lyakh Sep 7, 2018
679b291
ASoC:core:bug fix: oops caused by pointer dereference.
Sep 4, 2018
64cf3e3
ASoC:topology:delete dynamic object during widget remove
Sep 10, 2018
ae5f868
ASoC: SOF: restore byte control data after resume
ranj063 Sep 9, 2018
b0266de
ASoC: SOF: Kconfig: add an item to force IPC position update for debug
keyonjie Sep 11, 2018
09bb006
ASoC: SOF: Intel: add no_ipc_position flag for position update
keyonjie Sep 13, 2018
d582fbe
ASoC: SOF: add pointer callback for dsp_ops
keyonjie Aug 10, 2018
5e64314
ASoC: SOF: HDA: add pcm_pointer callback
keyonjie Aug 9, 2018
60d3d04
ASoC: SOF: PCM: change IPC stream params in platform hw_params().
keyonjie Sep 4, 2018
1fb7cfa
ASoC: SOF: Intel: correct BDL settings for DPIB/posbuf mode
keyonjie Sep 10, 2018
3e80cfb
ASoC: SOF: Intel: correct period settings for hdac_stream
keyonjie Sep 11, 2018
540aea4
ASoC: SOF: apl: add pcm_pointer callback to dsp_ops
keyonjie Aug 9, 2018
a224ab2
ASoC: SOF: only elapse/inform ALSA for irq mode
keyonjie Sep 14, 2018
50792bc
ASoC: SOF: skl enable the skl/kbl ops, instead of using apl_ops v2
zhuyingjiang Sep 14, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arch/arm/boot/dts/bcm2836-rpi-2-b.dts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "bcm2835-rpi.dtsi"
#include "bcm283x-rpi-smsc9514.dtsi"
#include "bcm283x-rpi-usb-host.dtsi"
#include "bcm283x-rpi-sof.dtsi"
//#include "bcm283x-rpi-sof.dtsi"

/ {
compatible = "raspberrypi,2-model-b", "brcm,bcm2836";
Expand Down
16 changes: 8 additions & 8 deletions include/sound/memalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@ struct snd_sg_buf {
struct device *dev;
};

/*
* return the pages matching with the given byte size
*/
static inline unsigned int snd_sgbuf_aligned_pages(size_t size)
{
return (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
}

/*
* return the physical address at the corresponding offset
*/
Expand Down Expand Up @@ -140,6 +132,14 @@ static inline void *snd_sgbuf_get_ptr(struct snd_dma_buffer *dmab,

#endif /* CONFIG_SND_DMA_SGBUF */

/*
* return the pages matching with the given byte size
*/
static inline unsigned int snd_sgbuf_aligned_pages(size_t size)
{
return (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
}

/* allocate/release a buffer */
int snd_dma_alloc_pages(int type, struct device *dev, size_t size,
struct snd_dma_buffer *dmab);
Expand Down
4 changes: 4 additions & 0 deletions include/sound/sof.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ struct snd_sof_pdata {
/* descriptor */
const struct sof_dev_desc *desc;

/* SPI data */
unsigned int gpio;
unsigned int active;

/* machine */
struct platform_device *pdev_mach;
union {
Expand Down
70 changes: 63 additions & 7 deletions include/uapi/sound/sof-eq.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,70 @@

#define SOF_EQ_FIR_MAX_SIZE 4096 /* Max size allowed for coef data in bytes */

#define SOF_EQ_FIR_MAX_LENGTH 192 /* Max length for individual filter */

/*
* eq_fir_configuration data structure contains this information
* uint32_t size
* This is the number of bytes need to store the received EQ
* configuration.
* uint16_t channels_in_config
* This describes the number of channels in this EQ config data. It
* can be different from PLATFORM_MAX_CHANNELS.
* uint16_t number_of_responses
* 0=no responses, 1=one response defined, 2=two responses defined, etc.
* int16_t data[]
* assign_response[STREAM_MAX_CHANNELS]
* -1 = not defined, 0 = use first response, 1 = use 2nd response, etc.
* E.g. {0, 0, 0, 0, -1, -1, -1, -1} would apply to channels 0-3 the
* same first defined response and leave channels 4-7 unequalized.
* assign_response[channels_in_config]
* 0 = use first response, 1 = use 2nd response, etc.
* E.g. {0, 0, 0, 0, 1, 1, 1, 1} would apply to channels 0-3 the
* same first defined response and for to channels 4-7 the second.
* coef_data[]
* Repeated data { filter_length, input_shift, output_shift, h[] }
* Repeated data
* { filter_length, output_shift, h[] }
* for every EQ response defined where vector h has filter_length
* number of coefficients. Coefficients in h[] are in Q1.15 format.
* E.g. 16384 (Q1.15) = 0.5. The shifts are number of right shifts.
*
* NOTE: The channels_in_config must be even to have coef_data aligned to
* 32 bit word in RAM. Therefore a mono EQ assign must be duplicated to 2ch
* even if it would never used. Similarly a 5ch EQ assign must be increased
* to 6ch. EQ init will return an error if this is not met.
*
* NOTE: The filter_length must be multiple of four. Therefore the filter must
* be padded from the end with zeros have this condition met.
*/

struct sof_eq_fir_config {
uint32_t size;
uint16_t channels_in_config;
uint16_t number_of_responses;
int16_t data[];
};

struct sof_eq_fir_coef_data {
int16_t length; /* Number of FIR taps */
int16_t out_shift; /* Amount of right shifts at output */
int16_t coef[]; /* FIR coefficients */
};

/* In the struct above there's two words (length, shift) before the actual
* FIR coefficients. This information is used in parsing of the config blob.
*/
#define SOF_EQ_FIR_COEF_NHEADER 2

/* IIR EQ type */

/* Component will reject non-matching configuration. The version number need
* to be incremented with any ABI changes in function fir_cmd().
*/
#define SOF_EQ_FIR_ABI_VERSION 1
#define SOF_EQ_IIR_ABI_VERSION 1

#define SOF_EQ_IIR_IDX_SWITCH 0

#define SOF_EQ_IIR_MAX_SIZE 1024 /* Max size allowed for coef data in bytes */

#define SOF_EQ_IIR_MAX_RESPONSES 8 /* A blob can define max 8 IIR EQs */

/* eq_iir_configuration
* uint32_t channels_in_config
* This describes the number of channels in this EQ config data. It
Expand Down Expand Up @@ -94,9 +122,37 @@ struct sof_eq_fir_config {
*/

struct sof_eq_iir_config {
uint32_t size;
uint32_t channels_in_config;
uint32_t number_of_responses;
int32_t data[];
int32_t data[]; /* eq_assign[channels], eq 0, eq 1, ... */
};

struct sof_eq_iir_header_df2t {
uint32_t num_sections;
uint32_t num_sections_in_series;
int32_t biquads[]; /* Repeated biquad coefficients */
};

struct sof_eq_iir_biquad_df2t {
int32_t a2; /* Q2.30 */
int32_t a1; /* Q2.30 */
int32_t b2; /* Q2.30 */
int32_t b1; /* Q2.30 */
int32_t b0; /* Q2.30 */
int32_t output_shift; /* Number of right shifts */
int32_t output_gain; /* Q2.14 */
};

/* A full 22th order equalizer with 11 biquads cover octave bands 1-11 in
* in the 0 - 20 kHz bandwidth.
*/
#define SOF_EQ_IIR_DF2T_BIQUADS_MAX 11

/* The number of int32_t words in sof_eq_iir_header_df2t */
#define SOF_EQ_IIR_NHEADER_DF2T 2

/* The number of int32_t words in sof_eq_iir_biquad_df2t */
#define SOF_EQ_IIR_NBIQUAD_DF2T 7

#endif /* EQ_H */
2 changes: 1 addition & 1 deletion include/uapi/sound/sof-ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
#define SOF_IPC_MESSAGE_ID(x) ((x) & 0xffff)

/* maximum message size for mailbox Tx/Rx */
#define SOF_IPC_MSG_MAX_SIZE 128
#define SOF_IPC_MSG_MAX_SIZE 384

/*
* SOF panic codes
Expand Down
10 changes: 10 additions & 0 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2168,11 +2168,21 @@ static int soc_probe(struct platform_device *pdev)
static int soc_cleanup_card_resources(struct snd_soc_card *card)
{
struct snd_soc_pcm_runtime *rtd;
struct snd_soc_component *component;
int ret;

/* make sure any delayed work runs */
list_for_each_entry(rtd, &card->rtd_list, list)
flush_delayed_work(&rtd->delayed_work);

/* remove dynamic controls for all component driver */
list_for_each_entry(component, &card->component_dev_list, card_list) {
ret = snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL);
if (ret < 0)
dev_err(component->dev,
"error: component free failed %d\n", ret);
}

/* free the ALSA card at first; this syncs with pending operations */
snd_card_free(card->snd_card);

Expand Down
3 changes: 3 additions & 0 deletions sound/soc/soc-dapm.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,7 @@ static int dapm_create_or_share_kcontrol(struct snd_soc_dapm_widget *w,
case snd_soc_dapm_switch:
case snd_soc_dapm_mixer:
case snd_soc_dapm_pga:
case snd_soc_dapm_effect:
case snd_soc_dapm_out_drv:
wname_in_long_name = true;
kcname_in_long_name = true;
Expand Down Expand Up @@ -2337,6 +2338,7 @@ static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt,
case snd_soc_dapm_dac:
case snd_soc_dapm_adc:
case snd_soc_dapm_pga:
case snd_soc_dapm_effect:
case snd_soc_dapm_out_drv:
case snd_soc_dapm_mixer:
case snd_soc_dapm_mixer_named_ctl:
Expand Down Expand Up @@ -3075,6 +3077,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card)
dapm_new_mux(w);
break;
case snd_soc_dapm_pga:
case snd_soc_dapm_effect:
case snd_soc_dapm_out_drv:
dapm_new_pga(w);
break;
Expand Down
1 change: 1 addition & 0 deletions sound/soc/soc-topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ static void remove_widget(struct snd_soc_component *comp,
}

free_news:
list_del(&dobj->list);
kfree(w->kcontrol_news);

/* widget w is freed by soc-dapm.c */
Expand Down
14 changes: 14 additions & 0 deletions sound/soc/sof/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,19 @@ config SND_SOC_SOF_DEBUG_VERBOSE_IPC
if you are trying to debug IPC with the DSP firmware.
If unsure select "N".

config SND_SOC_SOF_DEBUG_FORCE_IPC_POSITION
bool "SOF force to use IPC for position update on SKL+"
depends on SND_SOC_SOF_DEBUG
default y
help
This option force to handle stream position update IPCs and run pcm
elapse to inform ALSA about that, on platforms (e.g. Intel SKL+) that
with other approach (e.g. HDAC DPIB/posbuf) to elapse PCM.
On platforms (e.g. Intel SKL-) where position update IPC is the only
one choice, this setting won't impact anything.
if you are trying to debug pointer update with position IPCs or where
DPIB/posbuf is not ready, select "Y".
If unsure select "N".

source "sound/soc/sof/intel/Kconfig"
source "sound/soc/sof/xtensa/Kconfig"
95 changes: 95 additions & 0 deletions sound/soc/sof/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,98 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol,
err);
return ret;
}

int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol,
const unsigned int __user *binary_data,
unsigned int size)
{
struct soc_bytes_ext *be =
(struct soc_bytes_ext *)kcontrol->private_value;
struct snd_sof_control *scontrol = be->dobj.private;
struct snd_sof_dev *sdev = scontrol->sdev;
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
u32 header[2];
int ret;
int err;
int length;
const int max_length = SOF_IPC_MSG_MAX_SIZE -
sizeof(struct sof_ipc_ctrl_data) -
sizeof(struct sof_abi_hdr);

ret = pm_runtime_get_sync(sdev->dev);
if (ret < 0) {
dev_err(sdev->dev, "error: bytes put failed to resume %d\n",
ret);
return ret;
}

/* the first two ints of the bytes data contain a dummy tag
* and the size, so copy from the 3rd int
* TODO: or should we send the size as well so the firmware
* can allocate memory accordingly?
*/
if (copy_from_user(&header, binary_data, 2*sizeof(u32)))
return -EFAULT;

length = header[1];
dev_dbg(sdev->dev, "size of bytes put data is %d\n", length);
if (length > max_length) {
dev_err(sdev->dev, "error: size is too large, bytes max is %d\n",
max_length);
ret = -EINVAL;
goto out;
}

if (copy_from_user(cdata->data->data, binary_data + 2, length))
return -EFAULT;

/* set the ABI header values */
cdata->data->magic = SOF_ABI_MAGIC;
cdata->data->abi = SOF_ABI_VERSION;
cdata->data->comp_abi = SOF_ABI_VERSION;

/* notify DSP of mixer updates */
snd_sof_ipc_set_comp_data(sdev->ipc, scontrol, SOF_IPC_COMP_SET_DATA,
SOF_CTRL_TYPE_DATA_SET, scontrol->cmd);


out:
pm_runtime_mark_last_busy(sdev->dev);
err = pm_runtime_put_autosuspend(sdev->dev);
if (err < 0)
dev_err(sdev->dev, "error: failed to idle %d\n", err);

return ret;
}

int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol,
unsigned int __user *binary_data,
unsigned int size)
{
struct soc_bytes_ext *be =
(struct soc_bytes_ext *)kcontrol->private_value;
struct snd_sof_control *scontrol = be->dobj.private;
struct snd_sof_dev *sdev = scontrol->sdev;
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
unsigned int tag = 0;

pm_runtime_get_sync(sdev->dev);

dev_dbg(sdev->dev, "getting data and command is %d\n", scontrol->cmd);
/* get all the mixer data from DSP */
snd_sof_ipc_get_comp_data(sdev->ipc, scontrol, SOF_IPC_COMP_GET_DATA,
SOF_CTRL_TYPE_DATA_GET, scontrol->cmd);

/* TODO: replace 252 with actual size */
if (copy_to_user(binary_data, &tag, sizeof(u32)))
return -EFAULT;
if (copy_to_user(binary_data + 1, &size, sizeof(u32)))
return -EFAULT;
if (copy_to_user(binary_data + 2, cdata->data->data,
SOF_IPC_MSG_MAX_SIZE - sizeof(struct sof_ipc_ctrl_data)))
return -EFAULT;

pm_runtime_mark_last_busy(sdev->dev);
pm_runtime_put_autosuspend(sdev->dev);
return 0;
}
2 changes: 1 addition & 1 deletion sound/soc/sof/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ int snd_sof_create_page_table(struct snd_sof_dev *sdev,
{
int i, pages;

pages = PAGE_ALIGN(size);
pages = snd_sgbuf_aligned_pages(size);

dev_dbg(sdev->dev, "generating page table for %p size 0x%zx pages %d\n",
dmab->area, size, pages);
Expand Down
Loading