Commit 5bcaca4b authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branch 'asoc/topic/component' into asoc-next

parents 832a9414 b2d9de54
......@@ -593,7 +593,6 @@ struct snd_soc_dapm_context {
struct device *dev; /* from parent - for debug */
struct snd_soc_component *component; /* parent component */
struct snd_soc_codec *codec; /* parent codec */
struct snd_soc_card *card; /* parent card */
/* used during DAPM updates */
......
......@@ -690,6 +690,17 @@ struct snd_soc_compr_ops {
struct snd_soc_component_driver {
const char *name;
/* Default control and setup, added after probe() is run */
const struct snd_kcontrol_new *controls;
unsigned int num_controls;
const struct snd_soc_dapm_widget *dapm_widgets;
unsigned int num_dapm_widgets;
const struct snd_soc_dapm_route *dapm_routes;
unsigned int num_dapm_routes;
int (*probe)(struct snd_soc_component *);
void (*remove)(struct snd_soc_component *);
/* DT */
int (*of_xlate_dai_name)(struct snd_soc_component *component,
struct of_phandle_args *args,
......@@ -697,6 +708,10 @@ struct snd_soc_component_driver {
void (*seq_notifier)(struct snd_soc_component *, enum snd_soc_dapm_type,
int subseq);
int (*stream_event)(struct snd_soc_component *, int event);
/* probe ordering - for components with runtime dependencies */
int probe_order;
int remove_order;
};
struct snd_soc_component {
......@@ -710,6 +725,7 @@ struct snd_soc_component {
unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */
unsigned int registered_as_component:1;
unsigned int probed:1;
struct list_head list;
......@@ -728,9 +744,35 @@ struct snd_soc_component {
struct mutex io_mutex;
#ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_root;
#endif
/*
* DO NOT use any of the fields below in drivers, they are temporary and
* are going to be removed again soon. If you use them in driver code the
* driver will be marked as BROKEN when these fields are removed.
*/
/* Don't use these, use snd_soc_component_get_dapm() */
struct snd_soc_dapm_context dapm;
struct snd_soc_dapm_context *dapm_ptr;
const struct snd_kcontrol_new *controls;
unsigned int num_controls;
const struct snd_soc_dapm_widget *dapm_widgets;
unsigned int num_dapm_widgets;
const struct snd_soc_dapm_route *dapm_routes;
unsigned int num_dapm_routes;
struct snd_soc_codec *codec;
int (*probe)(struct snd_soc_component *);
void (*remove)(struct snd_soc_component *);
#ifdef CONFIG_DEBUG_FS
void (*init_debugfs)(struct snd_soc_component *component);
const char *debugfs_prefix;
#endif
};
/* SoC Audio Codec device */
......@@ -746,11 +788,9 @@ struct snd_soc_codec {
struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
unsigned int cache_bypass:1; /* Suppress access to the cache */
unsigned int suspended:1; /* Codec is in suspend PM state */
unsigned int probed:1; /* Codec has been probed */
unsigned int ac97_registered:1; /* Codec has been AC97 registered */
unsigned int ac97_created:1; /* Codec has been created by SoC */
unsigned int cache_init:1; /* codec cache has been initialized */
u32 cache_only; /* Suppress writes to hardware */
u32 cache_sync; /* Cache needs to be synced to hardware */
/* codec IO */
......@@ -766,7 +806,6 @@ struct snd_soc_codec {
struct snd_soc_dapm_context dapm;
#ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_codec_root;
struct dentry *debugfs_reg;
#endif
};
......@@ -813,10 +852,6 @@ struct snd_soc_codec_driver {
enum snd_soc_dapm_type, int);
bool ignore_pmdown_time; /* Doesn't benefit from pmdown delay */
/* probe ordering - for components with runtime dependencies */
int probe_order;
int remove_order;
};
/* SoC platform interface */
......@@ -832,14 +867,6 @@ struct snd_soc_platform_driver {
int (*pcm_new)(struct snd_soc_pcm_runtime *);
void (*pcm_free)(struct snd_pcm *);
/* Default control and setup, added after probe() is run */
const struct snd_kcontrol_new *controls;
int num_controls;
const struct snd_soc_dapm_widget *dapm_widgets;
int num_dapm_widgets;
const struct snd_soc_dapm_route *dapm_routes;
int num_dapm_routes;
/*
* For platform caused delay reporting.
* Optional.
......@@ -853,13 +880,6 @@ struct snd_soc_platform_driver {
/* platform stream compress ops */
const struct snd_compr_ops *compr_ops;
/* probe ordering - for components with runtime dependencies */
int probe_order;
int remove_order;
/* platform IO - used for platform DAPM */
unsigned int (*read)(struct snd_soc_platform *, unsigned int);
int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
int (*bespoke_trigger)(struct snd_pcm_substream *, int);
};
......@@ -874,15 +894,10 @@ struct snd_soc_platform {
const struct snd_soc_platform_driver *driver;
unsigned int suspended:1; /* platform is suspended */
unsigned int probed:1;
struct list_head list;
struct snd_soc_component component;
#ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_platform_root;
#endif
};
struct snd_soc_dai_link {
......@@ -994,7 +1009,7 @@ struct snd_soc_aux_dev {
const struct device_node *codec_of_node;
/* codec/machine specific init - e.g. add machine controls */
int (*init)(struct snd_soc_dapm_context *dapm);
int (*init)(struct snd_soc_component *component);
};
/* SoC card */
......@@ -1112,6 +1127,7 @@ struct snd_soc_pcm_runtime {
struct snd_soc_platform *platform;
struct snd_soc_dai *codec_dai;
struct snd_soc_dai *cpu_dai;
struct snd_soc_component *component; /* Only valid for AUX dev rtds */
struct snd_soc_dai **codec_dais;
unsigned int num_codecs;
......@@ -1260,9 +1276,6 @@ void snd_soc_component_async_complete(struct snd_soc_component *component);
int snd_soc_component_test_bits(struct snd_soc_component *component,
unsigned int reg, unsigned int mask, unsigned int value);
int snd_soc_component_init_io(struct snd_soc_component *component,
struct regmap *regmap);
/* device driver data */
static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,
......@@ -1276,26 +1289,37 @@ static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card)
return card->drvdata;
}
static inline void snd_soc_component_set_drvdata(struct snd_soc_component *c,
void *data)
{
dev_set_drvdata(c->dev, data);
}
static inline void *snd_soc_component_get_drvdata(struct snd_soc_component *c)
{
return dev_get_drvdata(c->dev);
}
static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec,
void *data)
{
dev_set_drvdata(codec->dev, data);
snd_soc_component_set_drvdata(&codec->component, data);
}
static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec)
{
return dev_get_drvdata(codec->dev);
return snd_soc_component_get_drvdata(&codec->component);
}
static inline void snd_soc_platform_set_drvdata(struct snd_soc_platform *platform,
void *data)
{
dev_set_drvdata(platform->dev, data);
snd_soc_component_set_drvdata(&platform->component, data);
}
static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platform)
{
return dev_get_drvdata(platform->dev);
return snd_soc_component_get_drvdata(&platform->component);
}
static inline void snd_soc_pcm_set_drvdata(struct snd_soc_pcm_runtime *rtd,
......
......@@ -212,7 +212,7 @@ static void wm8350_pga_work(struct work_struct *work)
{
struct snd_soc_dapm_context *dapm =
container_of(work, struct snd_soc_dapm_context, delayed_work.work);
struct snd_soc_codec *codec = dapm->codec;
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm);
struct wm8350_data *wm8350_data = snd_soc_codec_get_drvdata(codec);
struct wm8350_output *out1 = &wm8350_data->out1,
*out2 = &wm8350_data->out2;
......
......@@ -1433,7 +1433,7 @@ static void wm8753_work(struct work_struct *work)
struct snd_soc_dapm_context *dapm =
container_of(work, struct snd_soc_dapm_context,
delayed_work.work);
struct snd_soc_codec *codec = dapm->codec;
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm);
wm8753_set_bias_level(codec, dapm->bias_level);
}
......
......@@ -615,7 +615,7 @@ static void wm8971_work(struct work_struct *work)
struct snd_soc_dapm_context *dapm =
container_of(work, struct snd_soc_dapm_context,
delayed_work.work);
struct snd_soc_codec *codec = dapm->codec;
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm);
wm8971_set_bias_level(codec, codec->dapm.bias_level);
}
......
......@@ -2,7 +2,8 @@
snd-soc-sst-dsp-objs := sst-dsp.o sst-firmware.o
snd-soc-sst-acpi-objs := sst-acpi.o
snd-soc-sst-mfld-platform-objs := sst-mfld-platform-pcm.o sst-mfld-platform-compress.o
snd-soc-sst-mfld-platform-objs := sst-mfld-platform-pcm.o \
sst-mfld-platform-compress.o sst-atom-controls.o
snd-soc-mfld-machine-objs := mfld_machine.o
obj-$(CONFIG_SND_SST_MFLD_PLATFORM) += snd-soc-sst-mfld-platform.o
......
/*
* sst-atom-controls.c - Intel MID Platform driver DPCM ALSA controls for Mrfld
*
* Copyright (C) 2013-14 Intel Corp
* Author: Omair Mohammed Abdullah <omair.m.abdullah@intel.com>
* Vinod Koul <vinod.koul@intel.com>
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/slab.h>
#include <sound/soc.h>
#include <sound/tlv.h>
#include "sst-mfld-platform.h"
#include "sst-atom-controls.h"
int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform)
{
int ret = 0;
struct sst_data *drv = snd_soc_platform_get_drvdata(platform);
drv->byte_stream = devm_kzalloc(platform->dev,
SST_MAX_BIN_BYTES, GFP_KERNEL);
if (!drv->byte_stream)
return -ENOMEM;
return ret;
}
/*
* sst-atom-controls.h - Intel MID Platform driver header file
*
* Copyright (C) 2013-14 Intel Corp
* Author: Ramesh Babu <ramesh.babu.koul@intel.com>
* Omair M Abdullah <omair.m.abdullah@intel.com>
......@@ -18,13 +20,293 @@
*
*/
#ifndef __SST_CONTROLS_V2_H__
#define __SST_CONTROLS_V2_H__
#ifndef __SST_ATOM_CONTROLS_H__
#define __SST_ATOM_CONTROLS_H__
enum {
MERR_DPCM_AUDIO = 0,
MERR_DPCM_COMPR,
};
/* define a bit for each mixer input */
#define SST_MIX_IP(x) (x)
#define SST_IP_CODEC0 SST_MIX_IP(2)
#define SST_IP_CODEC1 SST_MIX_IP(3)
#define SST_IP_LOOP0 SST_MIX_IP(4)
#define SST_IP_LOOP1 SST_MIX_IP(5)
#define SST_IP_LOOP2 SST_MIX_IP(6)
#define SST_IP_PROBE SST_MIX_IP(7)
#define SST_IP_VOIP SST_MIX_IP(12)
#define SST_IP_PCM0 SST_MIX_IP(13)
#define SST_IP_PCM1 SST_MIX_IP(14)
#define SST_IP_MEDIA0 SST_MIX_IP(17)
#define SST_IP_MEDIA1 SST_MIX_IP(18)
#define SST_IP_MEDIA2 SST_MIX_IP(19)
#define SST_IP_MEDIA3 SST_MIX_IP(20)
#define SST_IP_LAST SST_IP_MEDIA3
#define SST_SWM_INPUT_COUNT (SST_IP_LAST + 1)
#define SST_CMD_SWM_MAX_INPUTS 6
#define SST_PATH_ID_SHIFT 8
#define SST_DEFAULT_LOCATION_ID 0xFFFF
#define SST_DEFAULT_CELL_NBR 0xFF
#define SST_DEFAULT_MODULE_ID 0xFFFF
/*
* Audio DSP Path Ids. Specified by the audio DSP FW
*/
enum sst_path_index {
SST_PATH_INDEX_CODEC_OUT0 = (0x02 << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_CODEC_OUT1 = (0x03 << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_SPROT_LOOP_OUT = (0x04 << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_MEDIA_LOOP1_OUT = (0x05 << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_MEDIA_LOOP2_OUT = (0x06 << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_VOIP_OUT = (0x0C << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_PCM0_OUT = (0x0D << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_PCM1_OUT = (0x0E << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_PCM2_OUT = (0x0F << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_MEDIA0_OUT = (0x12 << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_MEDIA1_OUT = (0x13 << SST_PATH_ID_SHIFT),
/* Start of input paths */
SST_PATH_INDEX_CODEC_IN0 = (0x82 << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_CODEC_IN1 = (0x83 << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_SPROT_LOOP_IN = (0x84 << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_MEDIA_LOOP1_IN = (0x85 << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_MEDIA_LOOP2_IN = (0x86 << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_VOIP_IN = (0x8C << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_PCM0_IN = (0x8D << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_PCM1_IN = (0x8E << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_MEDIA0_IN = (0x8F << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_MEDIA1_IN = (0x90 << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_MEDIA2_IN = (0x91 << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_MEDIA3_IN = (0x9C << SST_PATH_ID_SHIFT),
SST_PATH_INDEX_RESERVED = (0xFF << SST_PATH_ID_SHIFT),
};
/*
* path IDs
*/
enum sst_swm_inputs {
SST_SWM_IN_CODEC0 = (SST_PATH_INDEX_CODEC_IN0 | SST_DEFAULT_CELL_NBR),
SST_SWM_IN_CODEC1 = (SST_PATH_INDEX_CODEC_IN1 | SST_DEFAULT_CELL_NBR),
SST_SWM_IN_SPROT_LOOP = (SST_PATH_INDEX_SPROT_LOOP_IN | SST_DEFAULT_CELL_NBR),
SST_SWM_IN_MEDIA_LOOP1 = (SST_PATH_INDEX_MEDIA_LOOP1_IN | SST_DEFAULT_CELL_NBR),
SST_SWM_IN_MEDIA_LOOP2 = (SST_PATH_INDEX_MEDIA_LOOP2_IN | SST_DEFAULT_CELL_NBR),
SST_SWM_IN_VOIP = (SST_PATH_INDEX_VOIP_IN | SST_DEFAULT_CELL_NBR),
SST_SWM_IN_PCM0 = (SST_PATH_INDEX_PCM0_IN | SST_DEFAULT_CELL_NBR),
SST_SWM_IN_PCM1 = (SST_PATH_INDEX_PCM1_IN | SST_DEFAULT_CELL_NBR),
SST_SWM_IN_MEDIA0 = (SST_PATH_INDEX_MEDIA0_IN | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
SST_SWM_IN_MEDIA1 = (SST_PATH_INDEX_MEDIA1_IN | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
SST_SWM_IN_MEDIA2 = (SST_PATH_INDEX_MEDIA2_IN | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
SST_SWM_IN_MEDIA3 = (SST_PATH_INDEX_MEDIA3_IN | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
SST_SWM_IN_END = (SST_PATH_INDEX_RESERVED | SST_DEFAULT_CELL_NBR)
};
/*
* path IDs
*/
enum sst_swm_outputs {
SST_SWM_OUT_CODEC0 = (SST_PATH_INDEX_CODEC_OUT0 | SST_DEFAULT_CELL_NBR),
SST_SWM_OUT_CODEC1 = (SST_PATH_INDEX_CODEC_OUT1 | SST_DEFAULT_CELL_NBR),
SST_SWM_OUT_SPROT_LOOP = (SST_PATH_INDEX_SPROT_LOOP_OUT | SST_DEFAULT_CELL_NBR),
SST_SWM_OUT_MEDIA_LOOP1 = (SST_PATH_INDEX_MEDIA_LOOP1_OUT | SST_DEFAULT_CELL_NBR),
SST_SWM_OUT_MEDIA_LOOP2 = (SST_PATH_INDEX_MEDIA_LOOP2_OUT | SST_DEFAULT_CELL_NBR),
SST_SWM_OUT_VOIP = (SST_PATH_INDEX_VOIP_OUT | SST_DEFAULT_CELL_NBR),
SST_SWM_OUT_PCM0 = (SST_PATH_INDEX_PCM0_OUT | SST_DEFAULT_CELL_NBR),
SST_SWM_OUT_PCM1 = (SST_PATH_INDEX_PCM1_OUT | SST_DEFAULT_CELL_NBR),
SST_SWM_OUT_PCM2 = (SST_PATH_INDEX_PCM2_OUT | SST_DEFAULT_CELL_NBR),
SST_SWM_OUT_MEDIA0 = (SST_PATH_INDEX_MEDIA0_OUT | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
SST_SWM_OUT_MEDIA1 = (SST_PATH_INDEX_MEDIA1_OUT | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
SST_SWM_OUT_END = (SST_PATH_INDEX_RESERVED | SST_DEFAULT_CELL_NBR),
};
enum sst_ipc_msg {
SST_IPC_IA_CMD = 1,
SST_IPC_IA_SET_PARAMS,
SST_IPC_IA_GET_PARAMS,
};
enum sst_cmd_type {
SST_CMD_BYTES_SET = 1,
SST_CMD_BYTES_GET = 2,
};
enum sst_task {
SST_TASK_SBA = 1,
SST_TASK_MMX,
};
enum sst_type {
SST_TYPE_CMD = 1,
SST_TYPE_PARAMS,
};
enum sst_flag {
SST_FLAG_BLOCKED = 1,
SST_FLAG_NONBLOCK,
};
/*
* Enumeration for indexing the gain cells in VB_SET_GAIN DSP command
*/
enum sst_gain_index {
/* GAIN IDs for SB task start here */
SST_GAIN_INDEX_CODEC_OUT0,
SST_GAIN_INDEX_CODEC_OUT1,
SST_GAIN_INDEX_CODEC_IN0,
SST_GAIN_INDEX_CODEC_IN1,
SST_GAIN_INDEX_SPROT_LOOP_OUT,
SST_GAIN_INDEX_MEDIA_LOOP1_OUT,
SST_GAIN_INDEX_MEDIA_LOOP2_OUT,
SST_GAIN_INDEX_PCM0_IN_LEFT,
SST_GAIN_INDEX_PCM0_IN_RIGHT,
SST_GAIN_INDEX_PCM1_OUT_LEFT,
SST_GAIN_INDEX_PCM1_OUT_RIGHT,
SST_GAIN_INDEX_PCM1_IN_LEFT,
SST_GAIN_INDEX_PCM1_IN_RIGHT,
SST_GAIN_INDEX_PCM2_OUT_LEFT,
SST_GAIN_INDEX_PCM2_OUT_RIGHT,
SST_GAIN_INDEX_VOIP_OUT,
SST_GAIN_INDEX_VOIP_IN,
/* Gain IDs for MMX task start here */
SST_GAIN_INDEX_MEDIA0_IN_LEFT,
SST_GAIN_INDEX_MEDIA0_IN_RIGHT,
SST_GAIN_INDEX_MEDIA1_IN_LEFT,
SST_GAIN_INDEX_MEDIA1_IN_RIGHT,
SST_GAIN_INDEX_MEDIA2_IN_LEFT,
SST_GAIN_INDEX_MEDIA2_IN_RIGHT,
SST_GAIN_INDEX_GAIN_END
};
/*
* Audio DSP module IDs specified by FW spec
* TODO: Update with all modules
*/
enum sst_module_id {
SST_MODULE_ID_PCM = 0x0001,
SST_MODULE_ID_MP3 = 0x0002,
SST_MODULE_ID_MP24 = 0x0003,
SST_MODULE_ID_AAC = 0x0004,
SST_MODULE_ID_AACP = 0x0005,
SST_MODULE_ID_EAACP = 0x0006,
SST_MODULE_ID_WMA9 = 0x0007,
SST_MODULE_ID_WMA10 = 0x0008,
SST_MODULE_ID_WMA10P = 0x0009,
SST_MODULE_ID_RA = 0x000A,
SST_MODULE_ID_DDAC3 = 0x000B,
SST_MODULE_ID_TRUE_HD = 0x000C,
SST_MODULE_ID_HD_PLUS = 0x000D,
SST_MODULE_ID_SRC = 0x0064,
SST_MODULE_ID_DOWNMIX = 0x0066,
SST_MODULE_ID_GAIN_CELL = 0x0067,
SST_MODULE_ID_SPROT = 0x006D,
SST_MODULE_ID_BASS_BOOST = 0x006E,
SST_MODULE_ID_STEREO_WDNG = 0x006F,
SST_MODULE_ID_AV_REMOVAL = 0x0070,
SST_MODULE_ID_MIC_EQ = 0x0071,
SST_MODULE_ID_SPL = 0x0072,
SST_MODULE_ID_ALGO_VTSV = 0x0073,
SST_MODULE_ID_NR = 0x0076,
SST_MODULE_ID_BWX = 0x0077,
SST_MODULE_ID_DRP = 0x0078,
SST_MODULE_ID_MDRP = 0x0079,
SST_MODULE_ID_ANA = 0x007A,
SST_MODULE_ID_AEC = 0x007B,
SST_MODULE_ID_NR_SNS = 0x007C,
SST_MODULE_ID_SER = 0x007D,
SST_MODULE_ID_AGC = 0x007E,
SST_MODULE_ID_CNI = 0x007F,
SST_MODULE_ID_CONTEXT_ALGO_AWARE = 0x0080,
SST_MODULE_ID_FIR_24 = 0x0081,
SST_MODULE_ID_IIR_24 = 0x0082,
SST_MODULE_ID_ASRC = 0x0083,
SST_MODULE_ID_TONE_GEN = 0x0084,
SST_MODULE_ID_BMF = 0x0086,
SST_MODULE_ID_EDL = 0x0087,
SST_MODULE_ID_GLC = 0x0088,
SST_MODULE_ID_FIR_16 = 0x0089,
SST_MODULE_ID_IIR_16 = 0x008A,
SST_MODULE_ID_DNR = 0x008B,
SST_MODULE_ID_VIRTUALIZER = 0x008C,
SST_MODULE_ID_VISUALIZATION = 0x008D,
SST_MODULE_ID_LOUDNESS_OPTIMIZER = 0x008E,
SST_MODULE_ID_REVERBERATION = 0x008F,
SST_MODULE_ID_CNI_TX = 0x0090,
SST_MODULE_ID_REF_LINE = 0x0091,
SST_MODULE_ID_VOLUME = 0x0092,
SST_MODULE_ID_FILT_DCR = 0x0094,
SST_MODULE_ID_SLV = 0x009A,
SST_MODULE_ID_NLF = 0x009B,
SST_MODULE_ID_TNR = 0x009C,
SST_MODULE_ID_WNR = 0x009D,
SST_MODULE_ID_LOG = 0xFF00,
SST_MODULE_ID_TASK = 0xFFFF,
};
enum sst_cmd {
SBA_IDLE = 14,
SBA_VB_SET_SPEECH_PATH = 26,
MMX_SET_GAIN = 33,
SBA_VB_SET_GAIN = 33,
FBA_VB_RX_CNI = 35,
MMX_SET_GAIN_TIMECONST = 36,
SBA_VB_SET_TIMECONST = 36,
SBA_VB_START = 85,
SBA_SET_SWM = 114,
SBA_SET_MDRP = 116,
SBA_HW_SET_SSP = 117,
SBA_SET_MEDIA_LOOP_MAP = 118,
SBA_SET_MEDIA_PATH = 119,
MMX_SET_MEDIA_PATH = 119,
SBA_VB_LPRO = 126,
SBA_VB_SET_FIR = 128,
SBA_VB_SET_IIR = 129,
SBA_SET_SSP_SLOT_MAP = 130,
};
enum sst_dsp_switch {
SST_SWITCH_OFF = 0,
SST_SWITCH_ON = 3,
};
enum sst_path_switch {
SST_PATH_OFF = 0,
SST_PATH_ON = 1,
};
enum sst_swm_state {
SST_SWM_OFF = 0,
SST_SWM_ON = 3,
};
#endif
......@@ -138,11 +138,10 @@ static inline unsigned int hsw_ipc_to_mixer(u32 value)
static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol);
struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol);
struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(cmpnt);
struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value;
struct hsw_priv_data *pdata =
snd_soc_platform_get_drvdata(platform);
struct hsw_pcm_data *pcm_data = &pdata->pcm[mc->reg];
struct sst_hsw *hsw = pdata->hsw;
u32 volume;
......@@ -176,11 +175,10 @@ static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol,
static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol);
struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol);
struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(cmpnt);
struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value;
struct hsw_priv_data *pdata =
snd_soc_platform_get_drvdata(platform);
struct hsw_pcm_data *pcm_data = &pdata->pcm[mc->reg];
struct sst_hsw *hsw = pdata->hsw;
u32 volume;
......@@ -208,8 +206,8 @@ static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol,
static int hsw_volume_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol);
struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform);
struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol);
struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(cmpnt);
struct sst_hsw *hsw = pdata->hsw;
u32 volume;
......@@ -233,8 +231,8 @@ static int hsw_volume_put(struct snd_kcontrol *kcontrol,
static int hsw_volume_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol);
struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform);
struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol);
struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(cmpnt);
struct sst_hsw *hsw = pdata->hsw;
unsigned int volume = 0;
......@@ -778,20 +776,11 @@ static const struct snd_soc_dapm_route graph[] = {
static int hsw_pcm_probe(struct snd_soc_platform *platform)
{
struct hsw_priv_data *priv_data = snd_soc_platform_get_drvdata(platform);
struct sst_pdata *pdata = dev_get_platdata(platform->dev);
struct hsw_priv_data *priv_data;
struct device *dma_dev;
struct device *dma_dev = pdata->dma_dev;
int i, ret = 0;
if (!pdata)
return -ENODEV;
dma_dev = pdata->dma_dev;
priv_data = devm_kzalloc(platform->dev, sizeof(*priv_data), GFP_KERNEL);
priv_data->hsw = pdata->dsp;
snd_soc_platform_set_drvdata(platform, priv_data);
/* allocate DSP buffer page tables */
for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) {
......@@ -848,27 +837,38 @@ static struct snd_soc_platform_driver hsw_soc_platform = {
.ops = &hsw_pcm_ops,
.pcm_new = hsw_pcm_new,
.pcm_free = hsw_pcm_free,
.controls = hsw_volume_controls,
.num_controls = ARRAY_SIZE(hsw_volume_controls),
.dapm_widgets = widgets,
.num_dapm_widgets = ARRAY_SIZE(widgets),
.dapm_routes = graph,
.num_dapm_routes = ARRAY_SIZE(graph),
};
static const struct snd_soc_component_driver hsw_dai_component = {
.name = "haswell-dai",
.name = "haswell-dai",
.controls = hsw_volume_controls,
.num_controls = ARRAY_SIZE(hsw_volume_controls),
.dapm_widgets = widgets,
.num_dapm_widgets = ARRAY_SIZE(widgets),
.dapm_routes = graph,
.num_dapm_routes = ARRAY_SIZE(graph),
};
static int hsw_pcm_dev_probe(struct platform_device *pdev)
{
struct sst_pdata *sst_pdata = dev_get_platdata(&pdev->dev);
struct hsw_priv_data *priv_data;
int ret;
if (!sst_pdata)
return -EINVAL;
priv_data = devm_kzalloc(&pdev->dev, sizeof(*priv_data), GFP_KERNEL);
if (!priv_data)
return -ENOMEM;
ret = sst_hsw_dsp_init(&pdev->dev, sst_pdata);
if (ret < 0)
return -ENODEV;
priv_data->hsw = sst_pdata->dsp;
platform_set_drvdata(pdev, priv_data);
ret = snd_soc_register_platform(&pdev->dev, &hsw_soc_platform);
if (ret < 0)
goto err_plat;
......
......@@ -86,7 +86,7 @@ static int sst_platform_compr_free(struct snd_compr_stream *cstream)
/*need to check*/
str_id = stream->id;
if (str_id)
ret_val = stream->compr_ops->close(str_id);
ret_val = stream->compr_ops->close(sst->dev, str_id);
module_put(sst->dev->driver->owner);
kfree(stream);
pr_debug("%s: %d\n", __func__, ret_val);
......@@ -158,7 +158,7 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream,
cb.drain_cb_param = cstream;
cb.drain_notify = sst_drain_notify;
retval = stream->compr_ops->open(&str_params, &cb);
retval = stream->compr_ops->open(sst->dev, &str_params, &cb);
if (retval < 0) {
pr_err("stream allocation failed %d\n", retval);
return retval;
......@@ -170,10 +170,30 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream,
static int sst_platform_compr_trigger(struct snd_compr_stream *cstream, int cmd)
{
struct sst_runtime_stream *stream =
cstream->runtime->private_data;
return stream->compr_ops->control(cmd, stream->id);
struct sst_runtime_stream *stream = cstream->runtime->private_data;
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
if (stream->compr_ops->stream_start)
return stream->compr_ops->stream_start(sst->dev, stream->id);
case SNDRV_PCM_TRIGGER_STOP:
if (stream->compr_ops->stream_drop)
return stream->compr_ops->stream_drop(sst->dev, stream->id);
case SND_COMPR_TRIGGER_DRAIN:
if (stream->compr_ops->stream_drain)
return stream->compr_ops->stream_drain(sst->dev, stream->id);
case SND_COMPR_TRIGGER_PARTIAL_DRAIN:
if (stream->compr_ops->stream_partial_drain)
return stream->compr_ops->stream_partial_drain(sst->dev, stream->id);
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
if (stream->compr_ops->stream_pause)
return stream->compr_ops->stream_pause(sst->dev, stream->id);
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
if (stream->compr_ops->stream_pause_release)
return stream->compr_ops->stream_pause_release(sst->dev, stream->id);
default:
return -EINVAL;
}
}
static int sst_platform_compr_pointer(struct snd_compr_stream *cstream,
......@@ -182,7 +202,7 @@ static int sst_platform_compr_pointer(struct snd_compr_stream *cstream,
struct sst_runtime_stream *stream;
stream = cstream->runtime->private_data;
stream->compr_ops->tstamp(stream->id, tstamp);
stream->compr_ops->tstamp(sst->dev, stream->id, tstamp);
tstamp->byte_offset = tstamp->copied_total %
(u32)cstream->runtime->buffer_size;
pr_debug("calc bytes offset/copied bytes as %d\n", tstamp->byte_offset);
......@@ -195,7 +215,7 @@ static int sst_platform_compr_ack(struct snd_compr_stream *cstream,
struct sst_runtime_stream *stream;
stream = cstream->runtime->private_data;
stream->compr_ops->ack(stream->id, (unsigned long)bytes);
stream->compr_ops->ack(sst->dev, stream->id, (unsigned long)bytes);
stream->bytes_written += bytes;
return 0;
......@@ -225,7 +245,7 @@ static int sst_platform_compr_set_metadata(struct snd_compr_stream *cstream,
struct sst_runtime_stream *stream =
cstream->runtime->private_data;
return stream->compr_ops->set_metadata(stream->id, metadata);
return stream->compr_ops->set_metadata(sst->dev, stream->id, metadata);
}
struct snd_compr_ops sst_platform_compr_ops = {
......
......@@ -277,7 +277,7 @@ static int sst_platform_alloc_stream(struct snd_pcm_substream *substream,
stream->stream_info.str_id = str_params.stream_id;
ret_val = stream->ops->open(&str_params);
ret_val = stream->ops->open(sst->dev, &str_params);
if (ret_val <= 0)
return ret_val;
......@@ -314,14 +314,12 @@ static int sst_platform_init_stream(struct snd_pcm_substream *substream)
stream->stream_info.arg = substream;
stream->stream_info.buffer_ptr = 0;
stream->stream_info.sfreq = substream->runtime->rate;
ret_val = stream->ops->device_control(
SST_SND_STREAM_INIT, &stream->stream_info);
ret_val = stream->ops->stream_init(sst->dev, &stream->stream_info);
if (ret_val)
pr_err("control_set ret error %d\n", ret_val);
return ret_val;
}
/* end -- helper functions */
static int sst_media_open(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
......@@ -373,7 +371,7 @@ static void sst_media_close(struct snd_pcm_substream *substream,
stream = substream->runtime->private_data;
str_id = stream->stream_info.str_id;
if (str_id)
ret_val = stream->ops->close(str_id);
ret_val = stream->ops->close(sst->dev, str_id);
module_put(sst->dev->driver->owner);
kfree(stream);
}
......@@ -403,8 +401,7 @@ static int sst_media_prepare(struct snd_pcm_substream *substream,
stream = substream->runtime->private_data;
str_id = stream->stream_info.str_id;
if (stream->stream_info.str_id) {
ret_val = stream->ops->device_control(
SST_SND_DROP, &str_id);
ret_val = stream->ops->stream_drop(sst->dev, str_id);
return ret_val;
}
......@@ -461,7 +458,7 @@ static int sst_platform_pcm_trigger(struct snd_pcm_substream *substream,
{
int ret_val = 0, str_id;
struct sst_runtime_stream *stream;
int str_cmd, status;
int status;
pr_debug("sst_platform_pcm_trigger called\n");
stream = substream->runtime->private_data;
......@@ -469,29 +466,29 @@ static int sst_platform_pcm_trigger(struct snd_pcm_substream *substream,
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
pr_debug("sst: Trigger Start\n");
str_cmd = SST_SND_START;
status = SST_PLATFORM_RUNNING;
stream->stream_info.arg = substream;
ret_val = stream->ops->stream_start(sst->dev, str_id);
break;
case SNDRV_PCM_TRIGGER_STOP:
pr_debug("sst: in stop\n");
str_cmd = SST_SND_DROP;
status = SST_PLATFORM_DROPPED;
ret_val = stream->ops->stream_drop(sst->dev, str_id);
break;
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
pr_debug("sst: in pause\n");
str_cmd = SST_SND_PAUSE;
status = SST_PLATFORM_PAUSED;
ret_val = stream->ops->stream_pause(sst->dev, str_id);
break;
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
pr_debug("sst: in pause release\n");
str_cmd = SST_SND_RESUME;
status = SST_PLATFORM_RUNNING;
ret_val = stream->ops->stream_pause_release(sst->dev, str_id);
break;
default:
return -EINVAL;
}
ret_val = stream->ops->device_control(str_cmd, &str_id);
if (!ret_val)
sst_set_stream_status(stream, status);
......@@ -511,8 +508,7 @@ static snd_pcm_uframes_t sst_platform_pcm_pointer
if (status == SST_PLATFORM_INIT)
return 0;
str_info = &stream->stream_info;
ret_val = stream->ops->device_control(
SST_SND_BUFFER_POINTER, str_info);
ret_val = stream->ops->stream_read_tstamp(sst->dev, str_info);
if (ret_val) {
pr_err("sst: error code = %d\n", ret_val);
return ret_val;
......@@ -554,7 +550,13 @@ static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd)
return retval;
}
static struct snd_soc_platform_driver sst_soc_platform_drv = {
static int sst_soc_probe(struct snd_soc_platform *platform)
{
return sst_dsp_init_v2_dpcm(platform);
}
static struct snd_soc_platform_driver sst_soc_platform_drv = {
.probe = sst_soc_probe,
.ops = &sst_platform_ops,
.compr_ops = &sst_platform_compr_ops,
.pcm_new = sst_pcm_new,
......
......@@ -54,20 +54,6 @@ enum sst_drv_status {
SST_PLATFORM_DROPPED,
};
enum sst_controls {
SST_SND_ALLOC = 0x00,
SST_SND_PAUSE = 0x01,
SST_SND_RESUME = 0x02,
SST_SND_DROP = 0x03,
SST_SND_FREE = 0x04,
SST_SND_BUFFER_POINTER = 0x05,
SST_SND_STREAM_INIT = 0x06,
SST_SND_START = 0x07,
SST_SET_BYTE_STREAM = 0x100A,
SST_GET_BYTE_STREAM = 0x100B,
SST_MAX_CONTROLS = SST_GET_BYTE_STREAM,
};
enum sst_stream_ops {
STREAM_OPS_PLAYBACK = 0,
STREAM_OPS_CAPTURE,
......@@ -113,24 +99,36 @@ struct sst_compress_cb {
struct compress_sst_ops {
const char *name;
int (*open) (struct snd_sst_params *str_params,
struct sst_compress_cb *cb);
int (*control) (unsigned int cmd, unsigned int str_id);
int (*tstamp) (unsigned int str_id, struct snd_compr_tstamp *tstamp);
int (*ack) (unsigned int str_id, unsigned long bytes);
int (*close) (unsigned int str_id);
int (*get_caps) (struct snd_compr_caps *caps);
int (*get_codec_caps) (struct snd_compr_codec_caps *codec);
int (*set_metadata) (unsigned int str_id,
int (*open)(struct device *dev,
struct snd_sst_params *str_params, struct sst_compress_cb *cb);
int (*stream_start)(struct device *dev, unsigned int str_id);
int (*stream_drop)(struct device *dev, unsigned int str_id);
int (*stream_drain)(struct device *dev, unsigned int str_id);
int (*stream_partial_drain)(struct device *dev, unsigned int str_id);
int (*stream_pause)(struct device *dev, unsigned int str_id);
int (*stream_pause_release)(struct device *dev, unsigned int str_id);
int (*tstamp)(struct device *dev, unsigned int str_id,
struct snd_compr_tstamp *tstamp);
int (*ack)(struct device *dev, unsigned int str_id,
unsigned long bytes);
int (*close)(struct device *dev, unsigned int str_id);
int (*get_caps)(struct snd_compr_caps *caps);
int (*get_codec_caps)(struct snd_compr_codec_caps *codec);
int (*set_metadata)(struct device *dev, unsigned int str_id,
struct snd_compr_metadata *mdata);
};
struct sst_ops {
int (*open) (struct snd_sst_params *str_param);
int (*device_control) (int cmd, void *arg);
int (*set_generic_params)(enum sst_controls cmd, void *arg);
int (*close) (unsigned int str_id);
int (*open) (struct device *dev, struct snd_sst_params *str_param);
int (*stream_init) (struct device *dev, struct pcm_stream_info *str_info);
int (*stream_start) (struct device *dev, int str_id);
int (*stream_drop) (struct device *dev, int str_id);
int (*stream_pause) (struct device *dev, int str_id);
int (*stream_pause_release) (struct device *dev, int str_id);
int (*stream_read_tstamp) (struct device *dev, struct pcm_stream_info *str_info);
int (*send_byte_stream)(struct device *dev, struct snd_sst_bytes_v2 *bytes);
int (*close) (struct device *dev, unsigned int str_id);
};
struct sst_runtime_stream {
......@@ -152,6 +150,8 @@ struct sst_device {
};
struct sst_data;
int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform);
void sst_set_stream_status(struct sst_runtime_stream *stream, int state);
int sst_fill_stream_params(void *substream, const struct sst_data *ctx,
struct snd_sst_params *str_params, bool is_compress);
......@@ -166,6 +166,7 @@ struct sst_algo_int_control_v2 {
struct sst_data {
struct platform_device *pdev;
struct sst_platform_data *pdata;
char *byte_stream;
struct mutex lock;
};
int sst_register_dsp(struct sst_device *sst);
......
......@@ -168,7 +168,7 @@ static int rx51_spk_event(struct snd_soc_dapm_widget *w,
static int rx51_hp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event)
{
struct snd_soc_codec *codec = w->dapm->codec;
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
if (SND_SOC_DAPM_EVENT_ON(event))
tpa6130a2_stereo_enable(codec, 1);
......
......@@ -228,10 +228,12 @@ static struct snd_soc_dai_link speyside_dai[] = {
},
};
static int speyside_wm9081_init(struct snd_soc_dapm_context *dapm)
static int speyside_wm9081_init(struct snd_soc_component *component)
{
struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
/* At any time the WM9081 is active it will have this clock */
return snd_soc_codec_set_sysclk(dapm->codec, WM9081_SYSCLK_MCLK, 0,
return snd_soc_codec_set_sysclk(codec, WM9081_SYSCLK_MCLK, 0,
MCLK_AUDIO_RATE, 0);
}
......
This diff is collapsed.
......@@ -3109,7 +3109,8 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
}
w->dapm = dapm;
w->codec = dapm->codec;
if (dapm->component)
w->codec = dapm->component->codec;
INIT_LIST_HEAD(&w->sources);
INIT_LIST_HEAD(&w->sinks);
INIT_LIST_HEAD(&w->list);
......
......@@ -336,10 +336,12 @@ static const struct snd_pcm_ops dmaengine_pcm_ops = {
};
static const struct snd_soc_platform_driver dmaengine_pcm_platform = {
.component_driver = {
.probe_order = SND_SOC_COMP_ORDER_LATE,
},
.ops = &dmaengine_pcm_ops,
.pcm_new = dmaengine_pcm_new,
.pcm_free = dmaengine_pcm_free,
.probe_order = SND_SOC_COMP_ORDER_LATE,
};
static const char * const dmaengine_pcm_dma_channel_names[] = {
......
......@@ -271,31 +271,3 @@ int snd_soc_platform_write(struct snd_soc_platform *platform,
return snd_soc_component_write(&platform->component, reg, val);
}
EXPORT_SYMBOL_GPL(snd_soc_platform_write);
/**
* snd_soc_component_init_io() - Initialize regmap IO
*
* @component: component to initialize
* @regmap: regmap instance to use for IO operations
*
* Return: 0 on success, a negative error code otherwise
*/
int snd_soc_component_init_io(struct snd_soc_component *component,
struct regmap *regmap)
{
int ret;
if (!regmap)
return -EINVAL;
ret = regmap_get_val_bytes(regmap);
/* Errors are legitimate for non-integer byte
* multiples */
if (ret > 0)
component->val_bytes = ret;
component->regmap = regmap;
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_component_init_io);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment