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 { ...@@ -593,7 +593,6 @@ struct snd_soc_dapm_context {
struct device *dev; /* from parent - for debug */ struct device *dev; /* from parent - for debug */
struct snd_soc_component *component; /* parent component */ struct snd_soc_component *component; /* parent component */
struct snd_soc_codec *codec; /* parent codec */
struct snd_soc_card *card; /* parent card */ struct snd_soc_card *card; /* parent card */
/* used during DAPM updates */ /* used during DAPM updates */
......
...@@ -690,6 +690,17 @@ struct snd_soc_compr_ops { ...@@ -690,6 +690,17 @@ struct snd_soc_compr_ops {
struct snd_soc_component_driver { struct snd_soc_component_driver {
const char *name; 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 */ /* DT */
int (*of_xlate_dai_name)(struct snd_soc_component *component, int (*of_xlate_dai_name)(struct snd_soc_component *component,
struct of_phandle_args *args, struct of_phandle_args *args,
...@@ -697,6 +708,10 @@ struct snd_soc_component_driver { ...@@ -697,6 +708,10 @@ struct snd_soc_component_driver {
void (*seq_notifier)(struct snd_soc_component *, enum snd_soc_dapm_type, void (*seq_notifier)(struct snd_soc_component *, enum snd_soc_dapm_type,
int subseq); int subseq);
int (*stream_event)(struct snd_soc_component *, int event); 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 { struct snd_soc_component {
...@@ -710,6 +725,7 @@ 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 ignore_pmdown_time:1; /* pmdown_time is ignored at stop */
unsigned int registered_as_component:1; unsigned int registered_as_component:1;
unsigned int probed:1;
struct list_head list; struct list_head list;
...@@ -728,9 +744,35 @@ struct snd_soc_component { ...@@ -728,9 +744,35 @@ struct snd_soc_component {
struct mutex io_mutex; 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() */ /* Don't use these, use snd_soc_component_get_dapm() */
struct snd_soc_dapm_context dapm; struct snd_soc_dapm_context dapm;
struct snd_soc_dapm_context *dapm_ptr; 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 */ /* SoC Audio Codec device */
...@@ -746,11 +788,9 @@ struct snd_soc_codec { ...@@ -746,11 +788,9 @@ struct snd_soc_codec {
struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
unsigned int cache_bypass:1; /* Suppress access to the cache */ unsigned int cache_bypass:1; /* Suppress access to the cache */
unsigned int suspended:1; /* Codec is in suspend PM state */ 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_registered:1; /* Codec has been AC97 registered */
unsigned int ac97_created:1; /* Codec has been created by SoC */ unsigned int ac97_created:1; /* Codec has been created by SoC */
unsigned int cache_init:1; /* codec cache has been initialized */ 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 */ u32 cache_sync; /* Cache needs to be synced to hardware */
/* codec IO */ /* codec IO */
...@@ -766,7 +806,6 @@ struct snd_soc_codec { ...@@ -766,7 +806,6 @@ struct snd_soc_codec {
struct snd_soc_dapm_context dapm; struct snd_soc_dapm_context dapm;
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_codec_root;
struct dentry *debugfs_reg; struct dentry *debugfs_reg;
#endif #endif
}; };
...@@ -813,10 +852,6 @@ struct snd_soc_codec_driver { ...@@ -813,10 +852,6 @@ struct snd_soc_codec_driver {
enum snd_soc_dapm_type, int); enum snd_soc_dapm_type, int);
bool ignore_pmdown_time; /* Doesn't benefit from pmdown delay */ 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 */ /* SoC platform interface */
...@@ -832,14 +867,6 @@ struct snd_soc_platform_driver { ...@@ -832,14 +867,6 @@ struct snd_soc_platform_driver {
int (*pcm_new)(struct snd_soc_pcm_runtime *); int (*pcm_new)(struct snd_soc_pcm_runtime *);
void (*pcm_free)(struct snd_pcm *); 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. * For platform caused delay reporting.
* Optional. * Optional.
...@@ -853,13 +880,6 @@ struct snd_soc_platform_driver { ...@@ -853,13 +880,6 @@ struct snd_soc_platform_driver {
/* platform stream compress ops */ /* platform stream compress ops */
const struct snd_compr_ops *compr_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); int (*bespoke_trigger)(struct snd_pcm_substream *, int);
}; };
...@@ -874,15 +894,10 @@ struct snd_soc_platform { ...@@ -874,15 +894,10 @@ struct snd_soc_platform {
const struct snd_soc_platform_driver *driver; const struct snd_soc_platform_driver *driver;
unsigned int suspended:1; /* platform is suspended */ unsigned int suspended:1; /* platform is suspended */
unsigned int probed:1;
struct list_head list; struct list_head list;
struct snd_soc_component component; struct snd_soc_component component;
#ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_platform_root;
#endif
}; };
struct snd_soc_dai_link { struct snd_soc_dai_link {
...@@ -994,7 +1009,7 @@ struct snd_soc_aux_dev { ...@@ -994,7 +1009,7 @@ struct snd_soc_aux_dev {
const struct device_node *codec_of_node; const struct device_node *codec_of_node;
/* codec/machine specific init - e.g. add machine controls */ /* 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 */ /* SoC card */
...@@ -1112,6 +1127,7 @@ struct snd_soc_pcm_runtime { ...@@ -1112,6 +1127,7 @@ struct snd_soc_pcm_runtime {
struct snd_soc_platform *platform; struct snd_soc_platform *platform;
struct snd_soc_dai *codec_dai; struct snd_soc_dai *codec_dai;
struct snd_soc_dai *cpu_dai; struct snd_soc_dai *cpu_dai;
struct snd_soc_component *component; /* Only valid for AUX dev rtds */
struct snd_soc_dai **codec_dais; struct snd_soc_dai **codec_dais;
unsigned int num_codecs; unsigned int num_codecs;
...@@ -1260,9 +1276,6 @@ void snd_soc_component_async_complete(struct snd_soc_component *component); ...@@ -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, int snd_soc_component_test_bits(struct snd_soc_component *component,
unsigned int reg, unsigned int mask, unsigned int value); 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 */ /* device driver data */
static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card, 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) ...@@ -1276,26 +1289,37 @@ static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card)
return card->drvdata; 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, static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec,
void *data) 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) 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, static inline void snd_soc_platform_set_drvdata(struct snd_soc_platform *platform,
void *data) 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) 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, 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) ...@@ -212,7 +212,7 @@ static void wm8350_pga_work(struct work_struct *work)
{ {
struct snd_soc_dapm_context *dapm = struct snd_soc_dapm_context *dapm =
container_of(work, struct snd_soc_dapm_context, delayed_work.work); 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_data *wm8350_data = snd_soc_codec_get_drvdata(codec);
struct wm8350_output *out1 = &wm8350_data->out1, struct wm8350_output *out1 = &wm8350_data->out1,
*out2 = &wm8350_data->out2; *out2 = &wm8350_data->out2;
......
...@@ -1433,7 +1433,7 @@ static void wm8753_work(struct work_struct *work) ...@@ -1433,7 +1433,7 @@ static void wm8753_work(struct work_struct *work)
struct snd_soc_dapm_context *dapm = struct snd_soc_dapm_context *dapm =
container_of(work, struct snd_soc_dapm_context, container_of(work, struct snd_soc_dapm_context,
delayed_work.work); 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); wm8753_set_bias_level(codec, dapm->bias_level);
} }
......
...@@ -615,7 +615,7 @@ static void wm8971_work(struct work_struct *work) ...@@ -615,7 +615,7 @@ static void wm8971_work(struct work_struct *work)
struct snd_soc_dapm_context *dapm = struct snd_soc_dapm_context *dapm =
container_of(work, struct snd_soc_dapm_context, container_of(work, struct snd_soc_dapm_context,
delayed_work.work); 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); wm8971_set_bias_level(codec, codec->dapm.bias_level);
} }
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
snd-soc-sst-dsp-objs := sst-dsp.o sst-firmware.o snd-soc-sst-dsp-objs := sst-dsp.o sst-firmware.o
snd-soc-sst-acpi-objs := sst-acpi.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 snd-soc-mfld-machine-objs := mfld_machine.o
obj-$(CONFIG_SND_SST_MFLD_PLATFORM) += snd-soc-sst-mfld-platform.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 * Copyright (C) 2013-14 Intel Corp
* Author: Ramesh Babu <ramesh.babu.koul@intel.com> * Author: Ramesh Babu <ramesh.babu.koul@intel.com>
* Omair M Abdullah <omair.m.abdullah@intel.com> * Omair M Abdullah <omair.m.abdullah@intel.com>
...@@ -18,13 +20,293 @@ ...@@ -18,13 +20,293 @@
* *
*/ */
#ifndef __SST_CONTROLS_V2_H__ #ifndef __SST_ATOM_CONTROLS_H__
#define __SST_CONTROLS_V2_H__ #define __SST_ATOM_CONTROLS_H__
enum { enum {
MERR_DPCM_AUDIO = 0, MERR_DPCM_AUDIO = 0,
MERR_DPCM_COMPR, 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 #endif
...@@ -138,11 +138,10 @@ static inline unsigned int hsw_ipc_to_mixer(u32 value) ...@@ -138,11 +138,10 @@ static inline unsigned int hsw_ipc_to_mixer(u32 value)
static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol, static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) 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 *mc =
(struct soc_mixer_control *)kcontrol->private_value; (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 hsw_pcm_data *pcm_data = &pdata->pcm[mc->reg];
struct sst_hsw *hsw = pdata->hsw; struct sst_hsw *hsw = pdata->hsw;
u32 volume; u32 volume;
...@@ -176,11 +175,10 @@ static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol, ...@@ -176,11 +175,10 @@ static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol,
static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol, static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) 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 *mc =
(struct soc_mixer_control *)kcontrol->private_value; (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 hsw_pcm_data *pcm_data = &pdata->pcm[mc->reg];
struct sst_hsw *hsw = pdata->hsw; struct sst_hsw *hsw = pdata->hsw;
u32 volume; u32 volume;
...@@ -208,8 +206,8 @@ static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol, ...@@ -208,8 +206,8 @@ static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol,
static int hsw_volume_put(struct snd_kcontrol *kcontrol, static int hsw_volume_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) 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_platform_get_drvdata(platform); struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(cmpnt);
struct sst_hsw *hsw = pdata->hsw; struct sst_hsw *hsw = pdata->hsw;
u32 volume; u32 volume;
...@@ -233,8 +231,8 @@ static int hsw_volume_put(struct snd_kcontrol *kcontrol, ...@@ -233,8 +231,8 @@ static int hsw_volume_put(struct snd_kcontrol *kcontrol,
static int hsw_volume_get(struct snd_kcontrol *kcontrol, static int hsw_volume_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) 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_platform_get_drvdata(platform); struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(cmpnt);
struct sst_hsw *hsw = pdata->hsw; struct sst_hsw *hsw = pdata->hsw;
unsigned int volume = 0; unsigned int volume = 0;
...@@ -778,20 +776,11 @@ static const struct snd_soc_dapm_route graph[] = { ...@@ -778,20 +776,11 @@ static const struct snd_soc_dapm_route graph[] = {
static int hsw_pcm_probe(struct snd_soc_platform *platform) 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 sst_pdata *pdata = dev_get_platdata(platform->dev);
struct hsw_priv_data *priv_data; struct device *dma_dev = pdata->dma_dev;
struct device *dma_dev;
int i, ret = 0; 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 */ /* allocate DSP buffer page tables */
for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) { for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) {
...@@ -848,27 +837,38 @@ static struct snd_soc_platform_driver hsw_soc_platform = { ...@@ -848,27 +837,38 @@ static struct snd_soc_platform_driver hsw_soc_platform = {
.ops = &hsw_pcm_ops, .ops = &hsw_pcm_ops,
.pcm_new = hsw_pcm_new, .pcm_new = hsw_pcm_new,
.pcm_free = hsw_pcm_free, .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 = { 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) static int hsw_pcm_dev_probe(struct platform_device *pdev)
{ {
struct sst_pdata *sst_pdata = dev_get_platdata(&pdev->dev); struct sst_pdata *sst_pdata = dev_get_platdata(&pdev->dev);
struct hsw_priv_data *priv_data;
int ret; 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); ret = sst_hsw_dsp_init(&pdev->dev, sst_pdata);
if (ret < 0) if (ret < 0)
return -ENODEV; return -ENODEV;
priv_data->hsw = sst_pdata->dsp;
platform_set_drvdata(pdev, priv_data);
ret = snd_soc_register_platform(&pdev->dev, &hsw_soc_platform); ret = snd_soc_register_platform(&pdev->dev, &hsw_soc_platform);
if (ret < 0) if (ret < 0)
goto err_plat; goto err_plat;
......
...@@ -86,7 +86,7 @@ static int sst_platform_compr_free(struct snd_compr_stream *cstream) ...@@ -86,7 +86,7 @@ static int sst_platform_compr_free(struct snd_compr_stream *cstream)
/*need to check*/ /*need to check*/
str_id = stream->id; str_id = stream->id;
if (str_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); module_put(sst->dev->driver->owner);
kfree(stream); kfree(stream);
pr_debug("%s: %d\n", __func__, ret_val); pr_debug("%s: %d\n", __func__, ret_val);
...@@ -158,7 +158,7 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream, ...@@ -158,7 +158,7 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream,
cb.drain_cb_param = cstream; cb.drain_cb_param = cstream;
cb.drain_notify = sst_drain_notify; 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) { if (retval < 0) {
pr_err("stream allocation failed %d\n", retval); pr_err("stream allocation failed %d\n", retval);
return retval; return retval;
...@@ -170,10 +170,30 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream, ...@@ -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) static int sst_platform_compr_trigger(struct snd_compr_stream *cstream, int cmd)
{ {
struct sst_runtime_stream *stream = struct sst_runtime_stream *stream = cstream->runtime->private_data;
cstream->runtime->private_data;
switch (cmd) {
return stream->compr_ops->control(cmd, stream->id); 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, 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, ...@@ -182,7 +202,7 @@ static int sst_platform_compr_pointer(struct snd_compr_stream *cstream,
struct sst_runtime_stream *stream; struct sst_runtime_stream *stream;
stream = cstream->runtime->private_data; 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 % tstamp->byte_offset = tstamp->copied_total %
(u32)cstream->runtime->buffer_size; (u32)cstream->runtime->buffer_size;
pr_debug("calc bytes offset/copied bytes as %d\n", tstamp->byte_offset); 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, ...@@ -195,7 +215,7 @@ static int sst_platform_compr_ack(struct snd_compr_stream *cstream,
struct sst_runtime_stream *stream; struct sst_runtime_stream *stream;
stream = cstream->runtime->private_data; 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; stream->bytes_written += bytes;
return 0; return 0;
...@@ -225,7 +245,7 @@ static int sst_platform_compr_set_metadata(struct snd_compr_stream *cstream, ...@@ -225,7 +245,7 @@ static int sst_platform_compr_set_metadata(struct snd_compr_stream *cstream,
struct sst_runtime_stream *stream = struct sst_runtime_stream *stream =
cstream->runtime->private_data; 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 = { struct snd_compr_ops sst_platform_compr_ops = {
......
...@@ -277,7 +277,7 @@ static int sst_platform_alloc_stream(struct snd_pcm_substream *substream, ...@@ -277,7 +277,7 @@ static int sst_platform_alloc_stream(struct snd_pcm_substream *substream,
stream->stream_info.str_id = str_params.stream_id; 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) if (ret_val <= 0)
return ret_val; return ret_val;
...@@ -314,14 +314,12 @@ static int sst_platform_init_stream(struct snd_pcm_substream *substream) ...@@ -314,14 +314,12 @@ static int sst_platform_init_stream(struct snd_pcm_substream *substream)
stream->stream_info.arg = substream; stream->stream_info.arg = substream;
stream->stream_info.buffer_ptr = 0; stream->stream_info.buffer_ptr = 0;
stream->stream_info.sfreq = substream->runtime->rate; stream->stream_info.sfreq = substream->runtime->rate;
ret_val = stream->ops->device_control( ret_val = stream->ops->stream_init(sst->dev, &stream->stream_info);
SST_SND_STREAM_INIT, &stream->stream_info);
if (ret_val) if (ret_val)
pr_err("control_set ret error %d\n", ret_val); pr_err("control_set ret error %d\n", ret_val);
return ret_val; return ret_val;
} }
/* end -- helper functions */
static int sst_media_open(struct snd_pcm_substream *substream, static int sst_media_open(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
...@@ -373,7 +371,7 @@ static void sst_media_close(struct snd_pcm_substream *substream, ...@@ -373,7 +371,7 @@ static void sst_media_close(struct snd_pcm_substream *substream,
stream = substream->runtime->private_data; stream = substream->runtime->private_data;
str_id = stream->stream_info.str_id; str_id = stream->stream_info.str_id;
if (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); module_put(sst->dev->driver->owner);
kfree(stream); kfree(stream);
} }
...@@ -403,8 +401,7 @@ static int sst_media_prepare(struct snd_pcm_substream *substream, ...@@ -403,8 +401,7 @@ static int sst_media_prepare(struct snd_pcm_substream *substream,
stream = substream->runtime->private_data; stream = substream->runtime->private_data;
str_id = stream->stream_info.str_id; str_id = stream->stream_info.str_id;
if (stream->stream_info.str_id) { if (stream->stream_info.str_id) {
ret_val = stream->ops->device_control( ret_val = stream->ops->stream_drop(sst->dev, str_id);
SST_SND_DROP, &str_id);
return ret_val; return ret_val;
} }
...@@ -461,7 +458,7 @@ static int sst_platform_pcm_trigger(struct snd_pcm_substream *substream, ...@@ -461,7 +458,7 @@ static int sst_platform_pcm_trigger(struct snd_pcm_substream *substream,
{ {
int ret_val = 0, str_id; int ret_val = 0, str_id;
struct sst_runtime_stream *stream; struct sst_runtime_stream *stream;
int str_cmd, status; int status;
pr_debug("sst_platform_pcm_trigger called\n"); pr_debug("sst_platform_pcm_trigger called\n");
stream = substream->runtime->private_data; stream = substream->runtime->private_data;
...@@ -469,29 +466,29 @@ static int sst_platform_pcm_trigger(struct snd_pcm_substream *substream, ...@@ -469,29 +466,29 @@ static int sst_platform_pcm_trigger(struct snd_pcm_substream *substream,
switch (cmd) { switch (cmd) {
case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_START:
pr_debug("sst: Trigger Start\n"); pr_debug("sst: Trigger Start\n");
str_cmd = SST_SND_START;
status = SST_PLATFORM_RUNNING; status = SST_PLATFORM_RUNNING;
stream->stream_info.arg = substream; stream->stream_info.arg = substream;
ret_val = stream->ops->stream_start(sst->dev, str_id);
break; break;
case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_STOP:
pr_debug("sst: in stop\n"); pr_debug("sst: in stop\n");
str_cmd = SST_SND_DROP;
status = SST_PLATFORM_DROPPED; status = SST_PLATFORM_DROPPED;
ret_val = stream->ops->stream_drop(sst->dev, str_id);
break; break;
case SNDRV_PCM_TRIGGER_PAUSE_PUSH: case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
pr_debug("sst: in pause\n"); pr_debug("sst: in pause\n");
str_cmd = SST_SND_PAUSE;
status = SST_PLATFORM_PAUSED; status = SST_PLATFORM_PAUSED;
ret_val = stream->ops->stream_pause(sst->dev, str_id);
break; break;
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
pr_debug("sst: in pause release\n"); pr_debug("sst: in pause release\n");
str_cmd = SST_SND_RESUME;
status = SST_PLATFORM_RUNNING; status = SST_PLATFORM_RUNNING;
ret_val = stream->ops->stream_pause_release(sst->dev, str_id);
break; break;
default: default:
return -EINVAL; return -EINVAL;
} }
ret_val = stream->ops->device_control(str_cmd, &str_id);
if (!ret_val) if (!ret_val)
sst_set_stream_status(stream, status); sst_set_stream_status(stream, status);
...@@ -511,8 +508,7 @@ static snd_pcm_uframes_t sst_platform_pcm_pointer ...@@ -511,8 +508,7 @@ static snd_pcm_uframes_t sst_platform_pcm_pointer
if (status == SST_PLATFORM_INIT) if (status == SST_PLATFORM_INIT)
return 0; return 0;
str_info = &stream->stream_info; str_info = &stream->stream_info;
ret_val = stream->ops->device_control( ret_val = stream->ops->stream_read_tstamp(sst->dev, str_info);
SST_SND_BUFFER_POINTER, str_info);
if (ret_val) { if (ret_val) {
pr_err("sst: error code = %d\n", ret_val); pr_err("sst: error code = %d\n", ret_val);
return ret_val; return ret_val;
...@@ -554,7 +550,13 @@ static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd) ...@@ -554,7 +550,13 @@ static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd)
return retval; 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, .ops = &sst_platform_ops,
.compr_ops = &sst_platform_compr_ops, .compr_ops = &sst_platform_compr_ops,
.pcm_new = sst_pcm_new, .pcm_new = sst_pcm_new,
......
...@@ -54,20 +54,6 @@ enum sst_drv_status { ...@@ -54,20 +54,6 @@ enum sst_drv_status {
SST_PLATFORM_DROPPED, 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 { enum sst_stream_ops {
STREAM_OPS_PLAYBACK = 0, STREAM_OPS_PLAYBACK = 0,
STREAM_OPS_CAPTURE, STREAM_OPS_CAPTURE,
...@@ -113,24 +99,36 @@ struct sst_compress_cb { ...@@ -113,24 +99,36 @@ struct sst_compress_cb {
struct compress_sst_ops { struct compress_sst_ops {
const char *name; const char *name;
int (*open) (struct snd_sst_params *str_params, int (*open)(struct device *dev,
struct sst_compress_cb *cb); struct snd_sst_params *str_params, struct sst_compress_cb *cb);
int (*control) (unsigned int cmd, unsigned int str_id); int (*stream_start)(struct device *dev, unsigned int str_id);
int (*tstamp) (unsigned int str_id, struct snd_compr_tstamp *tstamp); int (*stream_drop)(struct device *dev, unsigned int str_id);
int (*ack) (unsigned int str_id, unsigned long bytes); int (*stream_drain)(struct device *dev, unsigned int str_id);
int (*close) (unsigned int str_id); int (*stream_partial_drain)(struct device *dev, unsigned int str_id);
int (*get_caps) (struct snd_compr_caps *caps); int (*stream_pause)(struct device *dev, unsigned int str_id);
int (*get_codec_caps) (struct snd_compr_codec_caps *codec); int (*stream_pause_release)(struct device *dev, unsigned int str_id);
int (*set_metadata) (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 snd_compr_metadata *mdata);
}; };
struct sst_ops { struct sst_ops {
int (*open) (struct snd_sst_params *str_param); int (*open) (struct device *dev, struct snd_sst_params *str_param);
int (*device_control) (int cmd, void *arg); int (*stream_init) (struct device *dev, struct pcm_stream_info *str_info);
int (*set_generic_params)(enum sst_controls cmd, void *arg); int (*stream_start) (struct device *dev, int str_id);
int (*close) (unsigned 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 { struct sst_runtime_stream {
...@@ -152,6 +150,8 @@ struct sst_device { ...@@ -152,6 +150,8 @@ struct sst_device {
}; };
struct sst_data; 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); void sst_set_stream_status(struct sst_runtime_stream *stream, int state);
int sst_fill_stream_params(void *substream, const struct sst_data *ctx, int sst_fill_stream_params(void *substream, const struct sst_data *ctx,
struct snd_sst_params *str_params, bool is_compress); struct snd_sst_params *str_params, bool is_compress);
...@@ -166,6 +166,7 @@ struct sst_algo_int_control_v2 { ...@@ -166,6 +166,7 @@ struct sst_algo_int_control_v2 {
struct sst_data { struct sst_data {
struct platform_device *pdev; struct platform_device *pdev;
struct sst_platform_data *pdata; struct sst_platform_data *pdata;
char *byte_stream;
struct mutex lock; struct mutex lock;
}; };
int sst_register_dsp(struct sst_device *sst); int sst_register_dsp(struct sst_device *sst);
......
...@@ -168,7 +168,7 @@ static int rx51_spk_event(struct snd_soc_dapm_widget *w, ...@@ -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, static int rx51_hp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) 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)) if (SND_SOC_DAPM_EVENT_ON(event))
tpa6130a2_stereo_enable(codec, 1); tpa6130a2_stereo_enable(codec, 1);
......
...@@ -228,10 +228,12 @@ static struct snd_soc_dai_link speyside_dai[] = { ...@@ -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 */ /* 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); MCLK_AUDIO_RATE, 0);
} }
......
...@@ -270,79 +270,54 @@ static const struct file_operations codec_reg_fops = { ...@@ -270,79 +270,54 @@ static const struct file_operations codec_reg_fops = {
.llseek = default_llseek, .llseek = default_llseek,
}; };
static struct dentry *soc_debugfs_create_dir(struct dentry *parent, static void soc_init_component_debugfs(struct snd_soc_component *component)
const char *fmt, ...)
{ {
struct dentry *de; if (component->debugfs_prefix) {
va_list ap; char *name;
char *s;
va_start(ap, fmt); name = kasprintf(GFP_KERNEL, "%s:%s",
s = kvasprintf(GFP_KERNEL, fmt, ap); component->debugfs_prefix, component->name);
va_end(ap); if (name) {
component->debugfs_root = debugfs_create_dir(name,
component->card->debugfs_card_root);
kfree(name);
}
} else {
component->debugfs_root = debugfs_create_dir(component->name,
component->card->debugfs_card_root);
}
if (!s) if (!component->debugfs_root) {
return NULL; dev_warn(component->dev,
"ASoC: Failed to create component debugfs directory\n");
return;
}
de = debugfs_create_dir(s, parent); snd_soc_dapm_debugfs_init(snd_soc_component_get_dapm(component),
kfree(s); component->debugfs_root);
return de; if (component->init_debugfs)
component->init_debugfs(component);
} }
static void soc_init_codec_debugfs(struct snd_soc_codec *codec) static void soc_cleanup_component_debugfs(struct snd_soc_component *component)
{ {
struct dentry *debugfs_card_root = codec->component.card->debugfs_card_root; debugfs_remove_recursive(component->debugfs_root);
}
codec->debugfs_codec_root = soc_debugfs_create_dir(debugfs_card_root, static void soc_init_codec_debugfs(struct snd_soc_component *component)
"codec:%s", {
codec->component.name); struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
if (!codec->debugfs_codec_root) {
dev_warn(codec->dev,
"ASoC: Failed to create codec debugfs directory\n");
return;
}
debugfs_create_bool("cache_sync", 0444, codec->debugfs_codec_root, debugfs_create_bool("cache_sync", 0444, codec->component.debugfs_root,
&codec->cache_sync); &codec->cache_sync);
debugfs_create_bool("cache_only", 0444, codec->debugfs_codec_root,
&codec->cache_only);
codec->debugfs_reg = debugfs_create_file("codec_reg", 0644, codec->debugfs_reg = debugfs_create_file("codec_reg", 0644,
codec->debugfs_codec_root, codec->component.debugfs_root,
codec, &codec_reg_fops); codec, &codec_reg_fops);
if (!codec->debugfs_reg) if (!codec->debugfs_reg)
dev_warn(codec->dev, dev_warn(codec->dev,
"ASoC: Failed to create codec register debugfs file\n"); "ASoC: Failed to create codec register debugfs file\n");
snd_soc_dapm_debugfs_init(&codec->dapm, codec->debugfs_codec_root);
}
static void soc_cleanup_codec_debugfs(struct snd_soc_codec *codec)
{
debugfs_remove_recursive(codec->debugfs_codec_root);
}
static void soc_init_platform_debugfs(struct snd_soc_platform *platform)
{
struct dentry *debugfs_card_root = platform->component.card->debugfs_card_root;
platform->debugfs_platform_root = soc_debugfs_create_dir(debugfs_card_root,
"platform:%s",
platform->component.name);
if (!platform->debugfs_platform_root) {
dev_warn(platform->dev,
"ASoC: Failed to create platform debugfs directory\n");
return;
}
snd_soc_dapm_debugfs_init(&platform->component.dapm,
platform->debugfs_platform_root);
}
static void soc_cleanup_platform_debugfs(struct snd_soc_platform *platform)
{
debugfs_remove_recursive(platform->debugfs_platform_root);
} }
static ssize_t codec_list_read_file(struct file *file, char __user *user_buf, static ssize_t codec_list_read_file(struct file *file, char __user *user_buf,
...@@ -474,19 +449,15 @@ static void soc_cleanup_card_debugfs(struct snd_soc_card *card) ...@@ -474,19 +449,15 @@ static void soc_cleanup_card_debugfs(struct snd_soc_card *card)
#else #else
static inline void soc_init_codec_debugfs(struct snd_soc_codec *codec) #define soc_init_codec_debugfs NULL
{
}
static inline void soc_cleanup_codec_debugfs(struct snd_soc_codec *codec)
{
}
static inline void soc_init_platform_debugfs(struct snd_soc_platform *platform) static inline void soc_init_component_debugfs(
struct snd_soc_component *component)
{ {
} }
static inline void soc_cleanup_platform_debugfs(struct snd_soc_platform *platform) static inline void soc_cleanup_component_debugfs(
struct snd_soc_component *component)
{ {
} }
...@@ -579,10 +550,8 @@ int snd_soc_suspend(struct device *dev) ...@@ -579,10 +550,8 @@ int snd_soc_suspend(struct device *dev)
struct snd_soc_codec *codec; struct snd_soc_codec *codec;
int i, j; int i, j;
/* If the initialization of this soc device failed, there is no codec /* If the card is not initialized yet there is nothing to do */
* associated with it. Just bail out in this case. if (!card->instantiated)
*/
if (list_empty(&card->codec_dev_list))
return 0; return 0;
/* Due to the resume being scheduled into a workqueue we could /* Due to the resume being scheduled into a workqueue we could
...@@ -835,10 +804,8 @@ int snd_soc_resume(struct device *dev) ...@@ -835,10 +804,8 @@ int snd_soc_resume(struct device *dev)
struct snd_soc_card *card = dev_get_drvdata(dev); struct snd_soc_card *card = dev_get_drvdata(dev);
int i, ac97_control = 0; int i, ac97_control = 0;
/* If the initialization of this soc device failed, there is no codec /* If the card is not initialized yet there is nothing to do */
* associated with it. Just bail out in this case. if (!card->instantiated)
*/
if (list_empty(&card->codec_dev_list))
return 0; return 0;
/* activate pins from sleep state */ /* activate pins from sleep state */
...@@ -887,35 +854,40 @@ EXPORT_SYMBOL_GPL(snd_soc_resume); ...@@ -887,35 +854,40 @@ EXPORT_SYMBOL_GPL(snd_soc_resume);
static const struct snd_soc_dai_ops null_dai_ops = { static const struct snd_soc_dai_ops null_dai_ops = {
}; };
static struct snd_soc_codec *soc_find_codec( static struct snd_soc_component *soc_find_component(
const struct device_node *codec_of_node, const struct device_node *of_node, const char *name)
const char *codec_name)
{ {
struct snd_soc_codec *codec; struct snd_soc_component *component;
list_for_each_entry(codec, &codec_list, list) { list_for_each_entry(component, &component_list, list) {
if (codec_of_node) { if (of_node) {
if (codec->dev->of_node != codec_of_node) if (component->dev->of_node == of_node)
continue; return component;
} else { } else if (strcmp(component->name, name) == 0) {
if (strcmp(codec->component.name, codec_name)) return component;
continue;
} }
return codec;
} }
return NULL; return NULL;
} }
static struct snd_soc_dai *soc_find_codec_dai(struct snd_soc_codec *codec, static struct snd_soc_dai *snd_soc_find_dai(
const char *codec_dai_name) const struct snd_soc_dai_link_component *dlc)
{ {
struct snd_soc_dai *codec_dai; struct snd_soc_component *component;
struct snd_soc_dai *dai;
list_for_each_entry(codec_dai, &codec->component.dai_list, list) { /* Find CPU DAI from registered DAIs*/
if (!strcmp(codec_dai->name, codec_dai_name)) { list_for_each_entry(component, &component_list, list) {
return codec_dai; if (dlc->of_node && component->dev->of_node != dlc->of_node)
continue;
if (dlc->name && strcmp(dev_name(component->dev), dlc->name))
continue;
list_for_each_entry(dai, &component->dai_list, list) {
if (dlc->dai_name && strcmp(dai->name, dlc->dai_name))
continue;
return dai;
} }
} }
...@@ -926,33 +898,19 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num) ...@@ -926,33 +898,19 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
{ {
struct snd_soc_dai_link *dai_link = &card->dai_link[num]; struct snd_soc_dai_link *dai_link = &card->dai_link[num];
struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
struct snd_soc_component *component;
struct snd_soc_dai_link_component *codecs = dai_link->codecs; struct snd_soc_dai_link_component *codecs = dai_link->codecs;
struct snd_soc_dai_link_component cpu_dai_component;
struct snd_soc_dai **codec_dais = rtd->codec_dais; struct snd_soc_dai **codec_dais = rtd->codec_dais;
struct snd_soc_platform *platform; struct snd_soc_platform *platform;
struct snd_soc_dai *cpu_dai;
const char *platform_name; const char *platform_name;
int i; int i;
dev_dbg(card->dev, "ASoC: binding %s at idx %d\n", dai_link->name, num); dev_dbg(card->dev, "ASoC: binding %s at idx %d\n", dai_link->name, num);
/* Find CPU DAI from registered DAIs*/ cpu_dai_component.name = dai_link->cpu_name;
list_for_each_entry(component, &component_list, list) { cpu_dai_component.of_node = dai_link->cpu_of_node;
if (dai_link->cpu_of_node && cpu_dai_component.dai_name = dai_link->cpu_dai_name;
component->dev->of_node != dai_link->cpu_of_node) rtd->cpu_dai = snd_soc_find_dai(&cpu_dai_component);
continue;
if (dai_link->cpu_name &&
strcmp(dev_name(component->dev), dai_link->cpu_name))
continue;
list_for_each_entry(cpu_dai, &component->dai_list, list) {
if (dai_link->cpu_dai_name &&
strcmp(cpu_dai->name, dai_link->cpu_dai_name))
continue;
rtd->cpu_dai = cpu_dai;
}
}
if (!rtd->cpu_dai) { if (!rtd->cpu_dai) {
dev_err(card->dev, "ASoC: CPU DAI %s not registered\n", dev_err(card->dev, "ASoC: CPU DAI %s not registered\n",
dai_link->cpu_dai_name); dai_link->cpu_dai_name);
...@@ -963,15 +921,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num) ...@@ -963,15 +921,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
/* Find CODEC from registered CODECs */ /* Find CODEC from registered CODECs */
for (i = 0; i < rtd->num_codecs; i++) { for (i = 0; i < rtd->num_codecs; i++) {
struct snd_soc_codec *codec; codec_dais[i] = snd_soc_find_dai(&codecs[i]);
codec = soc_find_codec(codecs[i].of_node, codecs[i].name);
if (!codec) {
dev_err(card->dev, "ASoC: CODEC %s not registered\n",
codecs[i].name);
return -EPROBE_DEFER;
}
codec_dais[i] = soc_find_codec_dai(codec, codecs[i].dai_name);
if (!codec_dais[i]) { if (!codec_dais[i]) {
dev_err(card->dev, "ASoC: CODEC DAI %s not registered\n", dev_err(card->dev, "ASoC: CODEC DAI %s not registered\n",
codecs[i].dai_name); codecs[i].dai_name);
...@@ -1012,68 +962,46 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num) ...@@ -1012,68 +962,46 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
return 0; return 0;
} }
static int soc_remove_platform(struct snd_soc_platform *platform) static void soc_remove_component(struct snd_soc_component *component)
{ {
int ret; if (!component->probed)
return;
if (platform->driver->remove) {
ret = platform->driver->remove(platform);
if (ret < 0)
dev_err(platform->dev, "ASoC: failed to remove %d\n",
ret);
}
/* Make sure all DAPM widgets are freed */
snd_soc_dapm_free(&platform->component.dapm);
soc_cleanup_platform_debugfs(platform);
platform->probed = 0;
module_put(platform->dev->driver->owner);
return 0;
}
static void soc_remove_codec(struct snd_soc_codec *codec) /* This is a HACK and will be removed soon */
{ if (component->codec)
int err; list_del(&component->codec->card_list);
if (codec->driver->remove) { if (component->remove)
err = codec->driver->remove(codec); component->remove(component);
if (err < 0)
dev_err(codec->dev, "ASoC: failed to remove %d\n", err);
}
/* Make sure all DAPM widgets are freed */ snd_soc_dapm_free(snd_soc_component_get_dapm(component));
snd_soc_dapm_free(&codec->dapm);
soc_cleanup_codec_debugfs(codec); soc_cleanup_component_debugfs(component);
codec->probed = 0; component->probed = 0;
list_del(&codec->card_list); module_put(component->dev->driver->owner);
module_put(codec->dev->driver->owner);
} }
static void soc_remove_codec_dai(struct snd_soc_dai *codec_dai, int order) static void soc_remove_dai(struct snd_soc_dai *dai, int order)
{ {
int err; int err;
if (codec_dai && codec_dai->probed && if (dai && dai->probed &&
codec_dai->driver->remove_order == order) { dai->driver->remove_order == order) {
if (codec_dai->driver->remove) { if (dai->driver->remove) {
err = codec_dai->driver->remove(codec_dai); err = dai->driver->remove(dai);
if (err < 0) if (err < 0)
dev_err(codec_dai->dev, dev_err(dai->dev,
"ASoC: failed to remove %s: %d\n", "ASoC: failed to remove %s: %d\n",
codec_dai->name, err); dai->name, err);
} }
codec_dai->probed = 0; dai->probed = 0;
} }
} }
static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order) static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order)
{ {
struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int i;
int i, err;
/* unregister the rtd device */ /* unregister the rtd device */
if (rtd->dev_registered) { if (rtd->dev_registered) {
...@@ -1085,22 +1013,9 @@ static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order) ...@@ -1085,22 +1013,9 @@ static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order)
/* remove the CODEC DAI */ /* remove the CODEC DAI */
for (i = 0; i < rtd->num_codecs; i++) for (i = 0; i < rtd->num_codecs; i++)
soc_remove_codec_dai(rtd->codec_dais[i], order); soc_remove_dai(rtd->codec_dais[i], order);
/* remove the cpu_dai */ soc_remove_dai(rtd->cpu_dai, order);
if (cpu_dai && cpu_dai->probed &&
cpu_dai->driver->remove_order == order) {
if (cpu_dai->driver->remove) {
err = cpu_dai->driver->remove(cpu_dai);
if (err < 0)
dev_err(cpu_dai->dev,
"ASoC: failed to remove %s: %d\n",
cpu_dai->name, err);
}
cpu_dai->probed = 0;
if (!cpu_dai->codec)
module_put(cpu_dai->dev->driver->owner);
}
} }
static void soc_remove_link_components(struct snd_soc_card *card, int num, static void soc_remove_link_components(struct snd_soc_card *card, int num,
...@@ -1109,29 +1024,24 @@ static void soc_remove_link_components(struct snd_soc_card *card, int num, ...@@ -1109,29 +1024,24 @@ static void soc_remove_link_components(struct snd_soc_card *card, int num,
struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct snd_soc_platform *platform = rtd->platform; struct snd_soc_platform *platform = rtd->platform;
struct snd_soc_codec *codec; struct snd_soc_component *component;
int i; int i;
/* remove the platform */ /* remove the platform */
if (platform && platform->probed && if (platform && platform->component.driver->remove_order == order)
platform->driver->remove_order == order) { soc_remove_component(&platform->component);
soc_remove_platform(platform);
}
/* remove the CODEC-side CODEC */ /* remove the CODEC-side CODEC */
for (i = 0; i < rtd->num_codecs; i++) { for (i = 0; i < rtd->num_codecs; i++) {
codec = rtd->codec_dais[i]->codec; component = rtd->codec_dais[i]->component;
if (codec && codec->probed && if (component->driver->remove_order == order)
codec->driver->remove_order == order) soc_remove_component(component);
soc_remove_codec(codec);
} }
/* remove any CPU-side CODEC */ /* remove any CPU-side CODEC */
if (cpu_dai) { if (cpu_dai) {
codec = cpu_dai->codec; if (cpu_dai->component->driver->remove_order == order)
if (codec && codec->probed && soc_remove_component(cpu_dai->component);
codec->driver->remove_order == order)
soc_remove_codec(codec);
} }
} }
...@@ -1173,137 +1083,78 @@ static void soc_set_name_prefix(struct snd_soc_card *card, ...@@ -1173,137 +1083,78 @@ static void soc_set_name_prefix(struct snd_soc_card *card,
} }
} }
static int soc_probe_codec(struct snd_soc_card *card, static int soc_probe_component(struct snd_soc_card *card,
struct snd_soc_codec *codec) struct snd_soc_component *component)
{ {
int ret = 0; struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
const struct snd_soc_codec_driver *driver = codec->driver;
struct snd_soc_dai *dai; struct snd_soc_dai *dai;
int ret;
if (component->probed)
return 0;
codec->component.card = card; component->card = card;
codec->dapm.card = card; dapm->card = card;
soc_set_name_prefix(card, &codec->component); soc_set_name_prefix(card, component);
if (!try_module_get(codec->dev->driver->owner)) if (!try_module_get(component->dev->driver->owner))
return -ENODEV; return -ENODEV;
soc_init_codec_debugfs(codec); soc_init_component_debugfs(component);
if (driver->dapm_widgets) { if (component->dapm_widgets) {
ret = snd_soc_dapm_new_controls(&codec->dapm, ret = snd_soc_dapm_new_controls(dapm, component->dapm_widgets,
driver->dapm_widgets, component->num_dapm_widgets);
driver->num_dapm_widgets);
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to create new controls %d\n", ret); "Failed to create new controls %d\n", ret);
goto err_probe; goto err_probe;
} }
} }
/* Create DAPM widgets for each DAI stream */ list_for_each_entry(dai, &component->dai_list, list) {
list_for_each_entry(dai, &codec->component.dai_list, list) { ret = snd_soc_dapm_new_dai_widgets(dapm, dai);
ret = snd_soc_dapm_new_dai_widgets(&codec->dapm, dai);
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to create DAI widgets %d\n", ret); "Failed to create DAI widgets %d\n", ret);
goto err_probe; goto err_probe;
} }
} }
codec->dapm.idle_bias_off = driver->idle_bias_off; if (component->probe) {
ret = component->probe(component);
if (driver->probe) {
ret = driver->probe(codec);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, dev_err(component->dev,
"ASoC: failed to probe CODEC %d\n", ret); "ASoC: failed to probe component %d\n", ret);
goto err_probe; goto err_probe;
} }
WARN(codec->dapm.idle_bias_off &&
codec->dapm.bias_level != SND_SOC_BIAS_OFF,
"codec %s can not start from non-off bias with idle_bias_off==1\n",
codec->component.name);
}
if (driver->controls)
snd_soc_add_codec_controls(codec, driver->controls,
driver->num_controls);
if (driver->dapm_routes)
snd_soc_dapm_add_routes(&codec->dapm, driver->dapm_routes,
driver->num_dapm_routes);
/* mark codec as probed and add to card codec list */
codec->probed = 1;
list_add(&codec->card_list, &card->codec_dev_list);
list_add(&codec->dapm.list, &card->dapm_list);
return 0;
err_probe:
soc_cleanup_codec_debugfs(codec);
module_put(codec->dev->driver->owner);
return ret;
}
static int soc_probe_platform(struct snd_soc_card *card,
struct snd_soc_platform *platform)
{
int ret = 0;
const struct snd_soc_platform_driver *driver = platform->driver;
struct snd_soc_component *component;
struct snd_soc_dai *dai;
platform->component.card = card;
platform->component.dapm.card = card;
if (!try_module_get(platform->dev->driver->owner))
return -ENODEV;
soc_init_platform_debugfs(platform);
if (driver->dapm_widgets) WARN(dapm->idle_bias_off &&
snd_soc_dapm_new_controls(&platform->component.dapm, dapm->bias_level != SND_SOC_BIAS_OFF,
driver->dapm_widgets, driver->num_dapm_widgets); "codec %s can not start from non-off bias with idle_bias_off==1\n",
component->name);
/* Create DAPM widgets for each DAI stream */
list_for_each_entry(component, &component_list, list) {
if (component->dev != platform->dev)
continue;
list_for_each_entry(dai, &component->dai_list, list)
snd_soc_dapm_new_dai_widgets(&platform->component.dapm,
dai);
} }
platform->component.dapm.idle_bias_off = 1; if (component->controls)
snd_soc_add_component_controls(component, component->controls,
component->num_controls);
if (component->dapm_routes)
snd_soc_dapm_add_routes(dapm, component->dapm_routes,
component->num_dapm_routes);
if (driver->probe) { component->probed = 1;
ret = driver->probe(platform); list_add(&dapm->list, &card->dapm_list);
if (ret < 0) {
dev_err(platform->dev,
"ASoC: failed to probe platform %d\n", ret);
goto err_probe;
}
}
if (driver->controls)
snd_soc_add_platform_controls(platform, driver->controls,
driver->num_controls);
if (driver->dapm_routes)
snd_soc_dapm_add_routes(&platform->component.dapm,
driver->dapm_routes, driver->num_dapm_routes);
/* mark platform as probed and add to card platform list */ /* This is a HACK and will be removed soon */
platform->probed = 1; if (component->codec)
list_add(&platform->component.dapm.list, &card->dapm_list); list_add(&component->codec->card_list, &card->codec_dev_list);
return 0; return 0;
err_probe: err_probe:
soc_cleanup_platform_debugfs(platform); soc_cleanup_component_debugfs(component);
module_put(platform->dev->driver->owner); module_put(component->dev->driver->owner);
return ret; return ret;
} }
...@@ -1342,17 +1193,21 @@ static int soc_post_component_init(struct snd_soc_pcm_runtime *rtd, ...@@ -1342,17 +1193,21 @@ static int soc_post_component_init(struct snd_soc_pcm_runtime *rtd,
} }
rtd->dev_registered = 1; rtd->dev_registered = 1;
/* add DAPM sysfs entries for this codec */ if (rtd->codec) {
ret = snd_soc_dapm_sys_add(rtd->dev); /* add DAPM sysfs entries for this codec */
if (ret < 0) ret = snd_soc_dapm_sys_add(rtd->dev);
dev_err(rtd->dev, if (ret < 0)
"ASoC: failed to add codec dapm sysfs entries: %d\n", ret); dev_err(rtd->dev,
"ASoC: failed to add codec dapm sysfs entries: %d\n",
ret);
/* add codec sysfs entries */ /* add codec sysfs entries */
ret = device_create_file(rtd->dev, &dev_attr_codec_reg); ret = device_create_file(rtd->dev, &dev_attr_codec_reg);
if (ret < 0) if (ret < 0)
dev_err(rtd->dev, dev_err(rtd->dev,
"ASoC: failed to add codec sysfs files: %d\n", ret); "ASoC: failed to add codec sysfs files: %d\n",
ret);
}
return 0; return 0;
} }
...@@ -1361,33 +1216,31 @@ static int soc_probe_link_components(struct snd_soc_card *card, int num, ...@@ -1361,33 +1216,31 @@ static int soc_probe_link_components(struct snd_soc_card *card, int num,
int order) int order)
{ {
struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct snd_soc_platform *platform = rtd->platform; struct snd_soc_platform *platform = rtd->platform;
struct snd_soc_component *component;
int i, ret; int i, ret;
/* probe the CPU-side component, if it is a CODEC */ /* probe the CPU-side component, if it is a CODEC */
if (cpu_dai->codec && component = rtd->cpu_dai->component;
!cpu_dai->codec->probed && if (component->driver->probe_order == order) {
cpu_dai->codec->driver->probe_order == order) { ret = soc_probe_component(card, component);
ret = soc_probe_codec(card, cpu_dai->codec);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
/* probe the CODEC-side components */ /* probe the CODEC-side components */
for (i = 0; i < rtd->num_codecs; i++) { for (i = 0; i < rtd->num_codecs; i++) {
if (!rtd->codec_dais[i]->codec->probed && component = rtd->codec_dais[i]->component;
rtd->codec_dais[i]->codec->driver->probe_order == order) { if (component->driver->probe_order == order) {
ret = soc_probe_codec(card, rtd->codec_dais[i]->codec); ret = soc_probe_component(card, component);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
} }
/* probe the platform */ /* probe the platform */
if (!platform->probed && if (platform->component.driver->probe_order == order) {
platform->driver->probe_order == order) { ret = soc_probe_component(card, &platform->component);
ret = soc_probe_platform(card, platform);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
...@@ -1482,18 +1335,12 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) ...@@ -1482,18 +1335,12 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)
/* probe the cpu_dai */ /* probe the cpu_dai */
if (!cpu_dai->probed && if (!cpu_dai->probed &&
cpu_dai->driver->probe_order == order) { cpu_dai->driver->probe_order == order) {
if (!cpu_dai->codec) {
if (!try_module_get(cpu_dai->dev->driver->owner))
return -ENODEV;
}
if (cpu_dai->driver->probe) { if (cpu_dai->driver->probe) {
ret = cpu_dai->driver->probe(cpu_dai); ret = cpu_dai->driver->probe(cpu_dai);
if (ret < 0) { if (ret < 0) {
dev_err(cpu_dai->dev, dev_err(cpu_dai->dev,
"ASoC: failed to probe CPU DAI %s: %d\n", "ASoC: failed to probe CPU DAI %s: %d\n",
cpu_dai->name, ret); cpu_dai->name, ret);
module_put(cpu_dai->dev->driver->owner);
return ret; return ret;
} }
} }
...@@ -1654,17 +1501,24 @@ static int soc_bind_aux_dev(struct snd_soc_card *card, int num) ...@@ -1654,17 +1501,24 @@ static int soc_bind_aux_dev(struct snd_soc_card *card, int num)
{ {
struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num]; struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num];
struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
const char *codecname = aux_dev->codec_name; const char *name = aux_dev->codec_name;
rtd->codec = soc_find_codec(aux_dev->codec_of_node, codecname); rtd->component = soc_find_component(aux_dev->codec_of_node, name);
if (!rtd->codec) { if (!rtd->component) {
if (aux_dev->codec_of_node) if (aux_dev->codec_of_node)
codecname = of_node_full_name(aux_dev->codec_of_node); name = of_node_full_name(aux_dev->codec_of_node);
dev_err(card->dev, "ASoC: %s not registered\n", codecname); dev_err(card->dev, "ASoC: %s not registered\n", name);
return -EPROBE_DEFER; return -EPROBE_DEFER;
} }
/*
* Some places still reference rtd->codec, so we have to keep that
* initialized if the component is a CODEC. Once all those references
* have been removed, this code can be removed as well.
*/
rtd->codec = rtd->component->codec;
return 0; return 0;
} }
...@@ -1674,18 +1528,13 @@ static int soc_probe_aux_dev(struct snd_soc_card *card, int num) ...@@ -1674,18 +1528,13 @@ static int soc_probe_aux_dev(struct snd_soc_card *card, int num)
struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
int ret; int ret;
if (rtd->codec->probed) { ret = soc_probe_component(card, rtd->component);
dev_err(rtd->codec->dev, "ASoC: codec already probed\n");
return -EBUSY;
}
ret = soc_probe_codec(card, rtd->codec);
if (ret < 0) if (ret < 0)
return ret; return ret;
/* do machine specific initialization */ /* do machine specific initialization */
if (aux_dev->init) { if (aux_dev->init) {
ret = aux_dev->init(&rtd->codec->dapm); ret = aux_dev->init(rtd->component);
if (ret < 0) { if (ret < 0) {
dev_err(card->dev, "ASoC: failed to init %s: %d\n", dev_err(card->dev, "ASoC: failed to init %s: %d\n",
aux_dev->name, ret); aux_dev->name, ret);
...@@ -1699,7 +1548,7 @@ static int soc_probe_aux_dev(struct snd_soc_card *card, int num) ...@@ -1699,7 +1548,7 @@ static int soc_probe_aux_dev(struct snd_soc_card *card, int num)
static void soc_remove_aux_dev(struct snd_soc_card *card, int num) static void soc_remove_aux_dev(struct snd_soc_card *card, int num)
{ {
struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num]; struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num];
struct snd_soc_codec *codec = rtd->codec; struct snd_soc_component *component = rtd->component;
/* unregister the rtd device */ /* unregister the rtd device */
if (rtd->dev_registered) { if (rtd->dev_registered) {
...@@ -1708,8 +1557,8 @@ static void soc_remove_aux_dev(struct snd_soc_card *card, int num) ...@@ -1708,8 +1557,8 @@ static void soc_remove_aux_dev(struct snd_soc_card *card, int num)
rtd->dev_registered = 0; rtd->dev_registered = 0;
} }
if (codec && codec->probed) if (component && component->probed)
soc_remove_codec(codec); soc_remove_component(component);
} }
static int snd_soc_init_codec_cache(struct snd_soc_codec *codec) static int snd_soc_init_codec_cache(struct snd_soc_codec *codec)
...@@ -4116,6 +3965,8 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, ...@@ -4116,6 +3965,8 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
component->dev = dev; component->dev = dev;
component->driver = driver; component->driver = driver;
component->probe = component->driver->probe;
component->remove = component->driver->remove;
if (!component->dapm_ptr) if (!component->dapm_ptr)
component->dapm_ptr = &component->dapm; component->dapm_ptr = &component->dapm;
...@@ -4124,19 +3975,42 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, ...@@ -4124,19 +3975,42 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
dapm->dev = dev; dapm->dev = dev;
dapm->component = component; dapm->component = component;
dapm->bias_level = SND_SOC_BIAS_OFF; dapm->bias_level = SND_SOC_BIAS_OFF;
dapm->idle_bias_off = true;
if (driver->seq_notifier) if (driver->seq_notifier)
dapm->seq_notifier = snd_soc_component_seq_notifier; dapm->seq_notifier = snd_soc_component_seq_notifier;
if (driver->stream_event) if (driver->stream_event)
dapm->stream_event = snd_soc_component_stream_event; dapm->stream_event = snd_soc_component_stream_event;
component->controls = driver->controls;
component->num_controls = driver->num_controls;
component->dapm_widgets = driver->dapm_widgets;
component->num_dapm_widgets = driver->num_dapm_widgets;
component->dapm_routes = driver->dapm_routes;
component->num_dapm_routes = driver->num_dapm_routes;
INIT_LIST_HEAD(&component->dai_list); INIT_LIST_HEAD(&component->dai_list);
mutex_init(&component->io_mutex); mutex_init(&component->io_mutex);
return 0; return 0;
} }
static void snd_soc_component_init_regmap(struct snd_soc_component *component)
{
if (!component->regmap)
component->regmap = dev_get_regmap(component->dev, NULL);
if (component->regmap) {
int val_bytes = regmap_get_val_bytes(component->regmap);
/* Errors are legitimate for non-integer byte multiples */
if (val_bytes > 0)
component->val_bytes = val_bytes;
}
}
static void snd_soc_component_add_unlocked(struct snd_soc_component *component) static void snd_soc_component_add_unlocked(struct snd_soc_component *component)
{ {
if (!component->write && !component->read)
snd_soc_component_init_regmap(component);
list_add(&component->list, &component_list); list_add(&component->list, &component_list);
} }
...@@ -4225,22 +4099,18 @@ void snd_soc_unregister_component(struct device *dev) ...@@ -4225,22 +4099,18 @@ void snd_soc_unregister_component(struct device *dev)
} }
EXPORT_SYMBOL_GPL(snd_soc_unregister_component); EXPORT_SYMBOL_GPL(snd_soc_unregister_component);
static int snd_soc_platform_drv_write(struct snd_soc_component *component, static int snd_soc_platform_drv_probe(struct snd_soc_component *component)
unsigned int reg, unsigned int val)
{ {
struct snd_soc_platform *platform = snd_soc_component_to_platform(component); struct snd_soc_platform *platform = snd_soc_component_to_platform(component);
return platform->driver->write(platform, reg, val); return platform->driver->probe(platform);
} }
static int snd_soc_platform_drv_read(struct snd_soc_component *component, static void snd_soc_platform_drv_remove(struct snd_soc_component *component)
unsigned int reg, unsigned int *val)
{ {
struct snd_soc_platform *platform = snd_soc_component_to_platform(component); struct snd_soc_platform *platform = snd_soc_component_to_platform(component);
*val = platform->driver->read(platform, reg); platform->driver->remove(platform);
return 0;
} }
/** /**
...@@ -4261,10 +4131,15 @@ int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, ...@@ -4261,10 +4131,15 @@ int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
platform->dev = dev; platform->dev = dev;
platform->driver = platform_drv; platform->driver = platform_drv;
if (platform_drv->write)
platform->component.write = snd_soc_platform_drv_write; if (platform_drv->probe)
if (platform_drv->read) platform->component.probe = snd_soc_platform_drv_probe;
platform->component.read = snd_soc_platform_drv_read; if (platform_drv->remove)
platform->component.remove = snd_soc_platform_drv_remove;
#ifdef CONFIG_DEBUG_FS
platform->component.debugfs_prefix = "platform";
#endif
mutex_lock(&client_mutex); mutex_lock(&client_mutex);
snd_soc_component_add_unlocked(&platform->component); snd_soc_component_add_unlocked(&platform->component);
...@@ -4386,6 +4261,20 @@ static void fixup_codec_formats(struct snd_soc_pcm_stream *stream) ...@@ -4386,6 +4261,20 @@ static void fixup_codec_formats(struct snd_soc_pcm_stream *stream)
stream->formats |= codec_format_map[i]; stream->formats |= codec_format_map[i];
} }
static int snd_soc_codec_drv_probe(struct snd_soc_component *component)
{
struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
return codec->driver->probe(codec);
}
static void snd_soc_codec_drv_remove(struct snd_soc_component *component)
{
struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
codec->driver->remove(codec);
}
static int snd_soc_codec_drv_write(struct snd_soc_component *component, static int snd_soc_codec_drv_write(struct snd_soc_component *component,
unsigned int reg, unsigned int val) unsigned int reg, unsigned int val)
{ {
...@@ -4424,7 +4313,6 @@ int snd_soc_register_codec(struct device *dev, ...@@ -4424,7 +4313,6 @@ int snd_soc_register_codec(struct device *dev,
{ {
struct snd_soc_codec *codec; struct snd_soc_codec *codec;
struct snd_soc_dai *dai; struct snd_soc_dai *dai;
struct regmap *regmap;
int ret, i; int ret, i;
dev_dbg(dev, "codec register %s\n", dev_name(dev)); dev_dbg(dev, "codec register %s\n", dev_name(dev));
...@@ -4434,18 +4322,36 @@ int snd_soc_register_codec(struct device *dev, ...@@ -4434,18 +4322,36 @@ int snd_soc_register_codec(struct device *dev,
return -ENOMEM; return -ENOMEM;
codec->component.dapm_ptr = &codec->dapm; codec->component.dapm_ptr = &codec->dapm;
codec->component.codec = codec;
ret = snd_soc_component_initialize(&codec->component, ret = snd_soc_component_initialize(&codec->component,
&codec_drv->component_driver, dev); &codec_drv->component_driver, dev);
if (ret) if (ret)
goto err_free; goto err_free;
if (codec_drv->controls) {
codec->component.controls = codec_drv->controls;
codec->component.num_controls = codec_drv->num_controls;
}
if (codec_drv->dapm_widgets) {
codec->component.dapm_widgets = codec_drv->dapm_widgets;
codec->component.num_dapm_widgets = codec_drv->num_dapm_widgets;
}
if (codec_drv->dapm_routes) {
codec->component.dapm_routes = codec_drv->dapm_routes;
codec->component.num_dapm_routes = codec_drv->num_dapm_routes;
}
if (codec_drv->probe)
codec->component.probe = snd_soc_codec_drv_probe;
if (codec_drv->remove)
codec->component.remove = snd_soc_codec_drv_remove;
if (codec_drv->write) if (codec_drv->write)
codec->component.write = snd_soc_codec_drv_write; codec->component.write = snd_soc_codec_drv_write;
if (codec_drv->read) if (codec_drv->read)
codec->component.read = snd_soc_codec_drv_read; codec->component.read = snd_soc_codec_drv_read;
codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time; codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time;
codec->dapm.codec = codec; codec->dapm.idle_bias_off = codec_drv->idle_bias_off;
if (codec_drv->seq_notifier) if (codec_drv->seq_notifier)
codec->dapm.seq_notifier = codec_drv->seq_notifier; codec->dapm.seq_notifier = codec_drv->seq_notifier;
if (codec_drv->set_bias_level) if (codec_drv->set_bias_level)
...@@ -4455,23 +4361,13 @@ int snd_soc_register_codec(struct device *dev, ...@@ -4455,23 +4361,13 @@ int snd_soc_register_codec(struct device *dev,
codec->component.val_bytes = codec_drv->reg_word_size; codec->component.val_bytes = codec_drv->reg_word_size;
mutex_init(&codec->mutex); mutex_init(&codec->mutex);
if (!codec->component.write) { #ifdef CONFIG_DEBUG_FS
if (codec_drv->get_regmap) codec->component.init_debugfs = soc_init_codec_debugfs;
regmap = codec_drv->get_regmap(dev); codec->component.debugfs_prefix = "codec";
else #endif
regmap = dev_get_regmap(dev, NULL);
if (codec_drv->get_regmap)
if (regmap) { codec->component.regmap = codec_drv->get_regmap(dev);
ret = snd_soc_component_init_io(&codec->component,
regmap);
if (ret) {
dev_err(codec->dev,
"Failed to set cache I/O:%d\n",
ret);
goto err_cleanup;
}
}
}
for (i = 0; i < num_dai; i++) { for (i = 0; i < num_dai; i++) {
fixup_codec_formats(&dai_drv[i].playback); fixup_codec_formats(&dai_drv[i].playback);
......
...@@ -3109,7 +3109,8 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, ...@@ -3109,7 +3109,8 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
} }
w->dapm = 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->sources);
INIT_LIST_HEAD(&w->sinks); INIT_LIST_HEAD(&w->sinks);
INIT_LIST_HEAD(&w->list); INIT_LIST_HEAD(&w->list);
......
...@@ -336,10 +336,12 @@ static const struct snd_pcm_ops dmaengine_pcm_ops = { ...@@ -336,10 +336,12 @@ static const struct snd_pcm_ops dmaengine_pcm_ops = {
}; };
static const struct snd_soc_platform_driver dmaengine_pcm_platform = { static const struct snd_soc_platform_driver dmaengine_pcm_platform = {
.component_driver = {
.probe_order = SND_SOC_COMP_ORDER_LATE,
},
.ops = &dmaengine_pcm_ops, .ops = &dmaengine_pcm_ops,
.pcm_new = dmaengine_pcm_new, .pcm_new = dmaengine_pcm_new,
.pcm_free = dmaengine_pcm_free, .pcm_free = dmaengine_pcm_free,
.probe_order = SND_SOC_COMP_ORDER_LATE,
}; };
static const char * const dmaengine_pcm_dma_channel_names[] = { static const char * const dmaengine_pcm_dma_channel_names[] = {
......
...@@ -271,31 +271,3 @@ int snd_soc_platform_write(struct snd_soc_platform *platform, ...@@ -271,31 +271,3 @@ int snd_soc_platform_write(struct snd_soc_platform *platform,
return snd_soc_component_write(&platform->component, reg, val); return snd_soc_component_write(&platform->component, reg, val);
} }
EXPORT_SYMBOL_GPL(snd_soc_platform_write); 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