mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 21:38:32 +08:00
Merge remote-tracking branches 'asoc/topic/topology', 'asoc/topic/twl6040', 'asoc/topic/wm5100', 'asoc/topic/wm8741' and 'asoc/topic/wm8960' into asoc-next
This commit is contained in:
commit
28bedc5946
@ -10,9 +10,20 @@ Required properties:
|
||||
- reg : the I2C address of the device for I2C, the chip select
|
||||
number for SPI.
|
||||
|
||||
Optional properties:
|
||||
|
||||
- diff-mode: Differential output mode configuration. Default value for field
|
||||
DIFF in register R8 (MODE_CONTROL_2). If absent, the default is 0, shall be:
|
||||
0 = stereo
|
||||
1 = mono left
|
||||
2 = stereo reversed
|
||||
3 = mono right
|
||||
|
||||
Example:
|
||||
|
||||
codec: wm8741@1a {
|
||||
compatible = "wlf,wm8741";
|
||||
reg = <0x1a>;
|
||||
|
||||
diff-mode = <3>;
|
||||
};
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <sound/control.h>
|
||||
#include <sound/soc-topology.h>
|
||||
#include <sound/asoc.h>
|
||||
|
||||
struct device;
|
||||
|
||||
@ -571,6 +573,7 @@ struct snd_soc_dapm_widget {
|
||||
int num_kcontrols;
|
||||
const struct snd_kcontrol_new *kcontrol_news;
|
||||
struct snd_kcontrol **kcontrols;
|
||||
struct snd_soc_dobj dobj;
|
||||
|
||||
/* widget input and outputs */
|
||||
struct list_head sources;
|
||||
|
168
include/sound/soc-topology.h
Normal file
168
include/sound/soc-topology.h
Normal file
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* linux/sound/soc-topology.h -- ALSA SoC Firmware Controls and DAPM
|
||||
*
|
||||
* Copyright (C) 2012 Texas Instruments Inc.
|
||||
* Copyright (C) 2015 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Simple file API to load FW that includes mixers, coefficients, DAPM graphs,
|
||||
* algorithms, equalisers, DAIs, widgets, FE caps, BE caps, codec link caps etc.
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_SND_SOC_TPLG_H
|
||||
#define __LINUX_SND_SOC_TPLG_H
|
||||
|
||||
#include <sound/asoc.h>
|
||||
#include <linux/list.h>
|
||||
|
||||
struct firmware;
|
||||
struct snd_kcontrol;
|
||||
struct snd_soc_tplg_pcm_be;
|
||||
struct snd_ctl_elem_value;
|
||||
struct snd_ctl_elem_info;
|
||||
struct snd_soc_dapm_widget;
|
||||
struct snd_soc_component;
|
||||
struct snd_soc_tplg_pcm_fe;
|
||||
struct snd_soc_dapm_context;
|
||||
struct snd_soc_card;
|
||||
|
||||
/* object scan be loaded and unloaded in groups with identfying indexes */
|
||||
#define SND_SOC_TPLG_INDEX_ALL 0 /* ID that matches all FW objects */
|
||||
|
||||
/* dynamic object type */
|
||||
enum snd_soc_dobj_type {
|
||||
SND_SOC_DOBJ_NONE = 0, /* object is not dynamic */
|
||||
SND_SOC_DOBJ_MIXER,
|
||||
SND_SOC_DOBJ_ENUM,
|
||||
SND_SOC_DOBJ_BYTES,
|
||||
SND_SOC_DOBJ_PCM,
|
||||
SND_SOC_DOBJ_DAI_LINK,
|
||||
SND_SOC_DOBJ_CODEC_LINK,
|
||||
SND_SOC_DOBJ_WIDGET,
|
||||
};
|
||||
|
||||
/* dynamic control object */
|
||||
struct snd_soc_dobj_control {
|
||||
struct snd_kcontrol *kcontrol;
|
||||
char **dtexts;
|
||||
unsigned long *dvalues;
|
||||
};
|
||||
|
||||
/* dynamic widget object */
|
||||
struct snd_soc_dobj_widget {
|
||||
unsigned int kcontrol_enum:1; /* this widget is an enum kcontrol */
|
||||
};
|
||||
|
||||
/* dynamic PCM DAI object */
|
||||
struct snd_soc_dobj_pcm_dai {
|
||||
struct snd_soc_tplg_pcm_dai *pd;
|
||||
unsigned int count;
|
||||
};
|
||||
|
||||
/* generic dynamic object - all dynamic objects belong to this struct */
|
||||
struct snd_soc_dobj {
|
||||
enum snd_soc_dobj_type type;
|
||||
unsigned int index; /* objects can belong in different groups */
|
||||
struct list_head list;
|
||||
struct snd_soc_tplg_ops *ops;
|
||||
union {
|
||||
struct snd_soc_dobj_control control;
|
||||
struct snd_soc_dobj_widget widget;
|
||||
struct snd_soc_dobj_pcm_dai pcm_dai;
|
||||
};
|
||||
void *private; /* core does not touch this */
|
||||
};
|
||||
|
||||
/*
|
||||
* Kcontrol operations - used to map handlers onto firmware based controls.
|
||||
*/
|
||||
struct snd_soc_tplg_kcontrol_ops {
|
||||
u32 id;
|
||||
int (*get)(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol);
|
||||
int (*put)(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol);
|
||||
int (*info)(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_info *uinfo);
|
||||
};
|
||||
|
||||
/*
|
||||
* DAPM widget event handlers - used to map handlers onto widgets.
|
||||
*/
|
||||
struct snd_soc_tplg_widget_events {
|
||||
u16 type;
|
||||
int (*event_handler)(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *k, int event);
|
||||
};
|
||||
|
||||
/*
|
||||
* Public API - Used by component drivers to load and unload dynamic objects
|
||||
* and their resources.
|
||||
*/
|
||||
struct snd_soc_tplg_ops {
|
||||
|
||||
/* external kcontrol init - used for any driver specific init */
|
||||
int (*control_load)(struct snd_soc_component *,
|
||||
struct snd_kcontrol_new *, struct snd_soc_tplg_ctl_hdr *);
|
||||
int (*control_unload)(struct snd_soc_component *,
|
||||
struct snd_soc_dobj *);
|
||||
|
||||
/* external widget init - used for any driver specific init */
|
||||
int (*widget_load)(struct snd_soc_component *,
|
||||
struct snd_soc_dapm_widget *,
|
||||
struct snd_soc_tplg_dapm_widget *);
|
||||
int (*widget_unload)(struct snd_soc_component *,
|
||||
struct snd_soc_dobj *);
|
||||
|
||||
/* FE - used for any driver specific init */
|
||||
int (*pcm_dai_load)(struct snd_soc_component *,
|
||||
struct snd_soc_tplg_pcm_dai *pcm_dai, int num_fe);
|
||||
int (*pcm_dai_unload)(struct snd_soc_component *,
|
||||
struct snd_soc_dobj *);
|
||||
|
||||
/* callback to handle vendor bespoke data */
|
||||
int (*vendor_load)(struct snd_soc_component *,
|
||||
struct snd_soc_tplg_hdr *);
|
||||
int (*vendor_unload)(struct snd_soc_component *,
|
||||
struct snd_soc_tplg_hdr *);
|
||||
|
||||
/* completion - called at completion of firmware loading */
|
||||
void (*complete)(struct snd_soc_component *);
|
||||
|
||||
/* manifest - optional to inform component of manifest */
|
||||
int (*manifest)(struct snd_soc_component *,
|
||||
struct snd_soc_tplg_manifest *);
|
||||
|
||||
/* bespoke kcontrol handlers available for binding */
|
||||
const struct snd_soc_tplg_kcontrol_ops *io_ops;
|
||||
int io_ops_count;
|
||||
};
|
||||
|
||||
/* gets a pointer to data from the firmware block header */
|
||||
static inline const void *snd_soc_tplg_get_data(struct snd_soc_tplg_hdr *hdr)
|
||||
{
|
||||
const void *ptr = hdr;
|
||||
|
||||
return ptr + sizeof(*hdr);
|
||||
}
|
||||
|
||||
/* Dynamic Object loading and removal for component drivers */
|
||||
int snd_soc_tplg_component_load(struct snd_soc_component *comp,
|
||||
struct snd_soc_tplg_ops *ops, const struct firmware *fw,
|
||||
u32 index);
|
||||
int snd_soc_tplg_component_remove(struct snd_soc_component *comp, u32 index);
|
||||
|
||||
/* Widget removal - widgets also removed wth component API */
|
||||
void snd_soc_tplg_widget_remove(struct snd_soc_dapm_widget *w);
|
||||
void snd_soc_tplg_widget_remove_all(struct snd_soc_dapm_context *dapm,
|
||||
u32 index);
|
||||
|
||||
/* Binds event handlers to dynamic widgets */
|
||||
int snd_soc_tplg_widget_bind_event(struct snd_soc_dapm_widget *w,
|
||||
const struct snd_soc_tplg_widget_events *events, int num_events,
|
||||
u16 event_type);
|
||||
|
||||
#endif
|
@ -27,6 +27,7 @@
|
||||
#include <sound/compress_driver.h>
|
||||
#include <sound/control.h>
|
||||
#include <sound/ac97_codec.h>
|
||||
#include <sound/soc-topology.h>
|
||||
|
||||
/*
|
||||
* Convenience kcontrol builders
|
||||
@ -776,6 +777,9 @@ struct snd_soc_component {
|
||||
|
||||
struct mutex io_mutex;
|
||||
|
||||
/* attached dynamic objects */
|
||||
struct list_head dobj_list;
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
struct dentry *debugfs_root;
|
||||
#endif
|
||||
@ -1123,6 +1127,9 @@ struct snd_soc_card {
|
||||
struct list_head dapm_list;
|
||||
struct list_head dapm_dirty;
|
||||
|
||||
/* attached dynamic objects */
|
||||
struct list_head dobj_list;
|
||||
|
||||
/* Generic DAPM context for the card */
|
||||
struct snd_soc_dapm_context dapm;
|
||||
struct snd_soc_dapm_stats dapm_stats;
|
||||
@ -1182,6 +1189,7 @@ struct soc_mixer_control {
|
||||
unsigned int sign_bit;
|
||||
unsigned int invert:1;
|
||||
unsigned int autodisable:1;
|
||||
struct snd_soc_dobj dobj;
|
||||
};
|
||||
|
||||
struct soc_bytes {
|
||||
@ -1192,6 +1200,8 @@ struct soc_bytes {
|
||||
|
||||
struct soc_bytes_ext {
|
||||
int max;
|
||||
struct snd_soc_dobj dobj;
|
||||
|
||||
/* used for TLV byte control */
|
||||
int (*get)(unsigned int __user *bytes, unsigned int size);
|
||||
int (*put)(const unsigned int __user *bytes, unsigned int size);
|
||||
@ -1213,6 +1223,7 @@ struct soc_enum {
|
||||
const char * const *texts;
|
||||
const unsigned int *values;
|
||||
unsigned int autodisable:1;
|
||||
struct snd_soc_dobj dobj;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -31,12 +31,7 @@
|
||||
* ~(sizeof(unsigned int) - 1)) ....
|
||||
*/
|
||||
|
||||
#define SNDRV_CTL_TLVT_CONTAINER 0 /* one level down - group of TLVs */
|
||||
#define SNDRV_CTL_TLVT_DB_SCALE 1 /* dB scale */
|
||||
#define SNDRV_CTL_TLVT_DB_LINEAR 2 /* linear volume */
|
||||
#define SNDRV_CTL_TLVT_DB_RANGE 3 /* dB range container */
|
||||
#define SNDRV_CTL_TLVT_DB_MINMAX 4 /* dB scale with min/max */
|
||||
#define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5 /* dB scale with min/max with mute */
|
||||
#include <uapi/sound/tlv.h>
|
||||
|
||||
#define TLV_ITEM(type, ...) \
|
||||
(type), TLV_LENGTH(__VA_ARGS__), __VA_ARGS__
|
||||
@ -90,12 +85,4 @@
|
||||
|
||||
#define TLV_DB_GAIN_MUTE -9999999
|
||||
|
||||
/*
|
||||
* channel-mapping TLV items
|
||||
* TLV length must match with num_channels
|
||||
*/
|
||||
#define SNDRV_CTL_TLVT_CHMAP_FIXED 0x101 /* fixed channel position */
|
||||
#define SNDRV_CTL_TLVT_CHMAP_VAR 0x102 /* channels freely swappable */
|
||||
#define SNDRV_CTL_TLVT_CHMAP_PAIRED 0x103 /* pair-wise swappable */
|
||||
|
||||
#endif /* __SOUND_TLV_H */
|
||||
|
388
include/uapi/sound/asoc.h
Normal file
388
include/uapi/sound/asoc.h
Normal file
@ -0,0 +1,388 @@
|
||||
/*
|
||||
* uapi/sound/asoc.h -- ALSA SoC Firmware Controls and DAPM
|
||||
*
|
||||
* Copyright (C) 2012 Texas Instruments Inc.
|
||||
* Copyright (C) 2015 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Simple file API to load FW that includes mixers, coefficients, DAPM graphs,
|
||||
* algorithms, equalisers, DAIs, widgets etc.
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_UAPI_SND_ASOC_H
|
||||
#define __LINUX_UAPI_SND_ASOC_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <sound/asound.h>
|
||||
|
||||
/*
|
||||
* Maximum number of channels topology kcontrol can represent.
|
||||
*/
|
||||
#define SND_SOC_TPLG_MAX_CHAN 8
|
||||
|
||||
/*
|
||||
* Maximum number of PCM formats capability
|
||||
*/
|
||||
#define SND_SOC_TPLG_MAX_FORMATS 16
|
||||
|
||||
/*
|
||||
* Maximum number of PCM stream configs
|
||||
*/
|
||||
#define SND_SOC_TPLG_STREAM_CONFIG_MAX 8
|
||||
|
||||
/* individual kcontrol info types - can be mixed with other types */
|
||||
#define SND_SOC_TPLG_CTL_VOLSW 1
|
||||
#define SND_SOC_TPLG_CTL_VOLSW_SX 2
|
||||
#define SND_SOC_TPLG_CTL_VOLSW_XR_SX 3
|
||||
#define SND_SOC_TPLG_CTL_ENUM 4
|
||||
#define SND_SOC_TPLG_CTL_BYTES 5
|
||||
#define SND_SOC_TPLG_CTL_ENUM_VALUE 6
|
||||
#define SND_SOC_TPLG_CTL_RANGE 7
|
||||
#define SND_SOC_TPLG_CTL_STROBE 8
|
||||
|
||||
|
||||
/* individual widget kcontrol info types - can be mixed with other types */
|
||||
#define SND_SOC_TPLG_DAPM_CTL_VOLSW 64
|
||||
#define SND_SOC_TPLG_DAPM_CTL_ENUM_DOUBLE 65
|
||||
#define SND_SOC_TPLG_DAPM_CTL_ENUM_VIRT 66
|
||||
#define SND_SOC_TPLG_DAPM_CTL_ENUM_VALUE 67
|
||||
#define SND_SOC_TPLG_DAPM_CTL_PIN 68
|
||||
|
||||
/* DAPM widget types - add new items to the end */
|
||||
#define SND_SOC_TPLG_DAPM_INPUT 0
|
||||
#define SND_SOC_TPLG_DAPM_OUTPUT 1
|
||||
#define SND_SOC_TPLG_DAPM_MUX 2
|
||||
#define SND_SOC_TPLG_DAPM_MIXER 3
|
||||
#define SND_SOC_TPLG_DAPM_PGA 4
|
||||
#define SND_SOC_TPLG_DAPM_OUT_DRV 5
|
||||
#define SND_SOC_TPLG_DAPM_ADC 6
|
||||
#define SND_SOC_TPLG_DAPM_DAC 7
|
||||
#define SND_SOC_TPLG_DAPM_SWITCH 8
|
||||
#define SND_SOC_TPLG_DAPM_PRE 9
|
||||
#define SND_SOC_TPLG_DAPM_POST 10
|
||||
#define SND_SOC_TPLG_DAPM_AIF_IN 11
|
||||
#define SND_SOC_TPLG_DAPM_AIF_OUT 12
|
||||
#define SND_SOC_TPLG_DAPM_DAI_IN 13
|
||||
#define SND_SOC_TPLG_DAPM_DAI_OUT 14
|
||||
#define SND_SOC_TPLG_DAPM_DAI_LINK 15
|
||||
#define SND_SOC_TPLG_DAPM_LAST SND_SOC_TPLG_DAPM_DAI_LINK
|
||||
|
||||
/* Header magic number and string sizes */
|
||||
#define SND_SOC_TPLG_MAGIC 0x41536F43 /* ASoC */
|
||||
|
||||
/* string sizes */
|
||||
#define SND_SOC_TPLG_NUM_TEXTS 16
|
||||
|
||||
/* ABI version */
|
||||
#define SND_SOC_TPLG_ABI_VERSION 0x2
|
||||
|
||||
/* Max size of TLV data */
|
||||
#define SND_SOC_TPLG_TLV_SIZE 32
|
||||
|
||||
/*
|
||||
* File and Block header data types.
|
||||
* Add new generic and vendor types to end of list.
|
||||
* Generic types are handled by the core whilst vendors types are passed
|
||||
* to the component drivers for handling.
|
||||
*/
|
||||
#define SND_SOC_TPLG_TYPE_MIXER 1
|
||||
#define SND_SOC_TPLG_TYPE_BYTES 2
|
||||
#define SND_SOC_TPLG_TYPE_ENUM 3
|
||||
#define SND_SOC_TPLG_TYPE_DAPM_GRAPH 4
|
||||
#define SND_SOC_TPLG_TYPE_DAPM_WIDGET 5
|
||||
#define SND_SOC_TPLG_TYPE_DAI_LINK 6
|
||||
#define SND_SOC_TPLG_TYPE_PCM 7
|
||||
#define SND_SOC_TPLG_TYPE_MANIFEST 8
|
||||
#define SND_SOC_TPLG_TYPE_CODEC_LINK 9
|
||||
#define SND_SOC_TPLG_TYPE_MAX SND_SOC_TPLG_TYPE_CODEC_LINK
|
||||
|
||||
/* vendor block IDs - please add new vendor types to end */
|
||||
#define SND_SOC_TPLG_TYPE_VENDOR_FW 1000
|
||||
#define SND_SOC_TPLG_TYPE_VENDOR_CONFIG 1001
|
||||
#define SND_SOC_TPLG_TYPE_VENDOR_COEFF 1002
|
||||
#define SND_SOC_TPLG_TYPEVENDOR_CODEC 1003
|
||||
|
||||
#define SND_SOC_TPLG_STREAM_PLAYBACK 0
|
||||
#define SND_SOC_TPLG_STREAM_CAPTURE 1
|
||||
|
||||
/*
|
||||
* Block Header.
|
||||
* This header preceeds all object and object arrays below.
|
||||
*/
|
||||
struct snd_soc_tplg_hdr {
|
||||
__le32 magic; /* magic number */
|
||||
__le32 abi; /* ABI version */
|
||||
__le32 version; /* optional vendor specific version details */
|
||||
__le32 type; /* SND_SOC_TPLG_TYPE_ */
|
||||
__le32 size; /* size of this structure */
|
||||
__le32 vendor_type; /* optional vendor specific type info */
|
||||
__le32 payload_size; /* data bytes, excluding this header */
|
||||
__le32 index; /* identifier for block */
|
||||
__le32 count; /* number of elements in block */
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* Private data.
|
||||
* All topology objects may have private data that can be used by the driver or
|
||||
* firmware. Core will ignore this data.
|
||||
*/
|
||||
struct snd_soc_tplg_private {
|
||||
__le32 size; /* in bytes of private data */
|
||||
char data[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* Kcontrol TLV data.
|
||||
*/
|
||||
struct snd_soc_tplg_ctl_tlv {
|
||||
__le32 size; /* in bytes aligned to 4 */
|
||||
__le32 numid; /* control element numeric identification */
|
||||
__le32 count; /* number of elem in data array */
|
||||
__le32 data[SND_SOC_TPLG_TLV_SIZE];
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* Kcontrol channel data
|
||||
*/
|
||||
struct snd_soc_tplg_channel {
|
||||
__le32 size; /* in bytes of this structure */
|
||||
__le32 reg;
|
||||
__le32 shift;
|
||||
__le32 id; /* ID maps to Left, Right, LFE etc */
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* Kcontrol Operations IDs
|
||||
*/
|
||||
struct snd_soc_tplg_kcontrol_ops_id {
|
||||
__le32 get;
|
||||
__le32 put;
|
||||
__le32 info;
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* kcontrol header
|
||||
*/
|
||||
struct snd_soc_tplg_ctl_hdr {
|
||||
__le32 size; /* in bytes of this structure */
|
||||
__le32 type;
|
||||
char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
|
||||
__le32 access;
|
||||
struct snd_soc_tplg_kcontrol_ops_id ops;
|
||||
__le32 tlv_size; /* non zero means control has TLV data */
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* Stream Capabilities
|
||||
*/
|
||||
struct snd_soc_tplg_stream_caps {
|
||||
__le32 size; /* in bytes of this structure */
|
||||
char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
|
||||
__le64 formats[SND_SOC_TPLG_MAX_FORMATS]; /* supported formats SNDRV_PCM_FMTBIT_* */
|
||||
__le32 rates; /* supported rates SNDRV_PCM_RATE_* */
|
||||
__le32 rate_min; /* min rate */
|
||||
__le32 rate_max; /* max rate */
|
||||
__le32 channels_min; /* min channels */
|
||||
__le32 channels_max; /* max channels */
|
||||
__le32 periods_min; /* min number of periods */
|
||||
__le32 periods_max; /* max number of periods */
|
||||
__le32 period_size_min; /* min period size bytes */
|
||||
__le32 period_size_max; /* max period size bytes */
|
||||
__le32 buffer_size_min; /* min buffer size bytes */
|
||||
__le32 buffer_size_max; /* max buffer size bytes */
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* FE or BE Stream configuration supported by SW/FW
|
||||
*/
|
||||
struct snd_soc_tplg_stream {
|
||||
__le32 size; /* in bytes of this structure */
|
||||
__le64 format; /* SNDRV_PCM_FMTBIT_* */
|
||||
__le32 rate; /* SNDRV_PCM_RATE_* */
|
||||
__le32 period_bytes; /* size of period in bytes */
|
||||
__le32 buffer_bytes; /* size of buffer in bytes */
|
||||
__le32 channels; /* channels */
|
||||
__le32 tdm_slot; /* optional BE bitmask of supported TDM slots */
|
||||
__le32 dai_fmt; /* SND_SOC_DAIFMT_ */
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* Duplex stream configuration supported by SW/FW.
|
||||
*/
|
||||
struct snd_soc_tplg_stream_config {
|
||||
__le32 size; /* in bytes of this structure */
|
||||
char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
|
||||
struct snd_soc_tplg_stream playback;
|
||||
struct snd_soc_tplg_stream capture;
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* Manifest. List totals for each payload type. Not used in parsing, but will
|
||||
* be passed to the component driver before any other objects in order for any
|
||||
* global componnent resource allocations.
|
||||
*
|
||||
* File block representation for manifest :-
|
||||
* +-----------------------------------+----+
|
||||
* | struct snd_soc_tplg_hdr | 1 |
|
||||
* +-----------------------------------+----+
|
||||
* | struct snd_soc_tplg_manifest | 1 |
|
||||
* +-----------------------------------+----+
|
||||
*/
|
||||
struct snd_soc_tplg_manifest {
|
||||
__le32 size; /* in bytes of this structure */
|
||||
__le32 control_elems; /* number of control elements */
|
||||
__le32 widget_elems; /* number of widget elements */
|
||||
__le32 graph_elems; /* number of graph elements */
|
||||
__le32 dai_elems; /* number of DAI elements */
|
||||
__le32 dai_link_elems; /* number of DAI link elements */
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* Mixer kcontrol.
|
||||
*
|
||||
* File block representation for mixer kcontrol :-
|
||||
* +-----------------------------------+----+
|
||||
* | struct snd_soc_tplg_hdr | 1 |
|
||||
* +-----------------------------------+----+
|
||||
* | struct snd_soc_tplg_mixer_control | N |
|
||||
* +-----------------------------------+----+
|
||||
*/
|
||||
struct snd_soc_tplg_mixer_control {
|
||||
struct snd_soc_tplg_ctl_hdr hdr;
|
||||
__le32 size; /* in bytes of this structure */
|
||||
__le32 min;
|
||||
__le32 max;
|
||||
__le32 platform_max;
|
||||
__le32 invert;
|
||||
__le32 num_channels;
|
||||
struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
|
||||
struct snd_soc_tplg_ctl_tlv tlv;
|
||||
struct snd_soc_tplg_private priv;
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* Enumerated kcontrol
|
||||
*
|
||||
* File block representation for enum kcontrol :-
|
||||
* +-----------------------------------+----+
|
||||
* | struct snd_soc_tplg_hdr | 1 |
|
||||
* +-----------------------------------+----+
|
||||
* | struct snd_soc_tplg_enum_control | N |
|
||||
* +-----------------------------------+----+
|
||||
*/
|
||||
struct snd_soc_tplg_enum_control {
|
||||
struct snd_soc_tplg_ctl_hdr hdr;
|
||||
__le32 size; /* in bytes of this structure */
|
||||
__le32 num_channels;
|
||||
struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
|
||||
__le32 items;
|
||||
__le32 mask;
|
||||
__le32 count;
|
||||
char texts[SND_SOC_TPLG_NUM_TEXTS][SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
|
||||
__le32 values[SND_SOC_TPLG_NUM_TEXTS * SNDRV_CTL_ELEM_ID_NAME_MAXLEN / 4];
|
||||
struct snd_soc_tplg_private priv;
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* Bytes kcontrol
|
||||
*
|
||||
* File block representation for bytes kcontrol :-
|
||||
* +-----------------------------------+----+
|
||||
* | struct snd_soc_tplg_hdr | 1 |
|
||||
* +-----------------------------------+----+
|
||||
* | struct snd_soc_tplg_bytes_control | N |
|
||||
* +-----------------------------------+----+
|
||||
*/
|
||||
struct snd_soc_tplg_bytes_control {
|
||||
struct snd_soc_tplg_ctl_hdr hdr;
|
||||
__le32 size; /* in bytes of this structure */
|
||||
__le32 max;
|
||||
__le32 mask;
|
||||
__le32 base;
|
||||
__le32 num_regs;
|
||||
struct snd_soc_tplg_private priv;
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* DAPM Graph Element
|
||||
*
|
||||
* File block representation for DAPM graph elements :-
|
||||
* +-------------------------------------+----+
|
||||
* | struct snd_soc_tplg_hdr | 1 |
|
||||
* +-------------------------------------+----+
|
||||
* | struct snd_soc_tplg_dapm_graph_elem | N |
|
||||
* +-------------------------------------+----+
|
||||
*/
|
||||
struct snd_soc_tplg_dapm_graph_elem {
|
||||
char sink[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
|
||||
char control[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
|
||||
char source[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* DAPM Widget.
|
||||
*
|
||||
* File block representation for DAPM widget :-
|
||||
* +-------------------------------------+-----+
|
||||
* | struct snd_soc_tplg_hdr | 1 |
|
||||
* +-------------------------------------+-----+
|
||||
* | struct snd_soc_tplg_dapm_widget | N |
|
||||
* +-------------------------------------+-----+
|
||||
* | struct snd_soc_tplg_enum_control | 0|1 |
|
||||
* | struct snd_soc_tplg_mixer_control | 0|N |
|
||||
* +-------------------------------------+-----+
|
||||
*
|
||||
* Optional enum or mixer control can be appended to the end of each widget
|
||||
* in the block.
|
||||
*/
|
||||
struct snd_soc_tplg_dapm_widget {
|
||||
__le32 size; /* in bytes of this structure */
|
||||
__le32 id; /* SND_SOC_DAPM_CTL */
|
||||
char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
|
||||
char sname[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
|
||||
|
||||
__le32 reg; /* negative reg = no direct dapm */
|
||||
__le32 shift; /* bits to shift */
|
||||
__le32 mask; /* non-shifted mask */
|
||||
__u32 invert; /* invert the power bit */
|
||||
__u32 ignore_suspend; /* kept enabled over suspend */
|
||||
__u16 event_flags;
|
||||
__u16 event_type;
|
||||
__u16 num_kcontrols;
|
||||
struct snd_soc_tplg_private priv;
|
||||
/*
|
||||
* kcontrols that relate to this widget
|
||||
* follow here after widget private data
|
||||
*/
|
||||
} __attribute__((packed));
|
||||
|
||||
struct snd_soc_tplg_pcm_cfg_caps {
|
||||
struct snd_soc_tplg_stream_caps caps;
|
||||
struct snd_soc_tplg_stream_config configs[SND_SOC_TPLG_STREAM_CONFIG_MAX];
|
||||
__le32 num_configs; /* number of configs */
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* Describes SW/FW specific features of PCM or DAI link.
|
||||
*
|
||||
* File block representation for PCM/DAI-Link :-
|
||||
* +-----------------------------------+-----+
|
||||
* | struct snd_soc_tplg_hdr | 1 |
|
||||
* +-----------------------------------+-----+
|
||||
* | struct snd_soc_tplg_dapm_pcm_dai | N |
|
||||
* +-----------------------------------+-----+
|
||||
*/
|
||||
struct snd_soc_tplg_pcm_dai {
|
||||
__le32 size; /* in bytes of this structure */
|
||||
char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
|
||||
__le32 id; /* unique ID - used to match */
|
||||
__le32 playback; /* supports playback mode */
|
||||
__le32 capture; /* supports capture mode */
|
||||
__le32 compress; /* 1 = compressed; 0 = PCM */
|
||||
struct snd_soc_tplg_pcm_cfg_caps capconf[2]; /* capabilities and configs */
|
||||
} __attribute__((packed));
|
||||
|
||||
#endif
|
31
include/uapi/sound/tlv.h
Normal file
31
include/uapi/sound/tlv.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __UAPI_SOUND_TLV_H
|
||||
#define __UAPI_SOUND_TLV_H
|
||||
|
||||
#define SNDRV_CTL_TLVT_CONTAINER 0 /* one level down - group of TLVs */
|
||||
#define SNDRV_CTL_TLVT_DB_SCALE 1 /* dB scale */
|
||||
#define SNDRV_CTL_TLVT_DB_LINEAR 2 /* linear volume */
|
||||
#define SNDRV_CTL_TLVT_DB_RANGE 3 /* dB range container */
|
||||
#define SNDRV_CTL_TLVT_DB_MINMAX 4 /* dB scale with min/max */
|
||||
#define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5 /* dB scale with min/max with mute */
|
||||
|
||||
/*
|
||||
* channel-mapping TLV items
|
||||
* TLV length must match with num_channels
|
||||
*/
|
||||
#define SNDRV_CTL_TLVT_CHMAP_FIXED 0x101 /* fixed channel position */
|
||||
#define SNDRV_CTL_TLVT_CHMAP_VAR 0x102 /* channels freely swappable */
|
||||
#define SNDRV_CTL_TLVT_CHMAP_PAIRED 0x103 /* pair-wise swappable */
|
||||
|
||||
#endif
|
@ -1,5 +1,6 @@
|
||||
snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o
|
||||
snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o soc-devres.o soc-ops.o
|
||||
snd-soc-core-objs += soc-topology.o
|
||||
|
||||
ifneq ($(CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM),)
|
||||
snd-soc-core-objs += soc-generic-dmaengine-pcm.o
|
||||
|
@ -1121,7 +1121,8 @@ static int twl6040_probe(struct snd_soc_codec *codec)
|
||||
mutex_init(&priv->mutex);
|
||||
|
||||
ret = request_threaded_irq(priv->plug_irq, NULL,
|
||||
twl6040_audio_handler, IRQF_NO_SUSPEND,
|
||||
twl6040_audio_handler,
|
||||
IRQF_NO_SUSPEND | IRQF_ONESHOT,
|
||||
"twl6040_irq_plug", codec);
|
||||
if (ret) {
|
||||
dev_err(codec->dev, "PLUG IRQ request failed: %d\n", ret);
|
||||
|
@ -2570,11 +2570,13 @@ static int wm5100_i2c_probe(struct i2c_client *i2c,
|
||||
|
||||
if (irq_flags & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING))
|
||||
ret = request_threaded_irq(i2c->irq, NULL,
|
||||
wm5100_edge_irq, irq_flags,
|
||||
wm5100_edge_irq,
|
||||
irq_flags | IRQF_ONESHOT,
|
||||
"wm5100", wm5100);
|
||||
else
|
||||
ret = request_threaded_irq(i2c->irq, NULL, wm5100_irq,
|
||||
irq_flags, "wm5100",
|
||||
irq_flags | IRQF_ONESHOT,
|
||||
"wm5100",
|
||||
wm5100);
|
||||
|
||||
if (ret != 0) {
|
||||
|
@ -41,6 +41,7 @@ static const char *wm8741_supply_names[WM8741_NUM_SUPPLIES] = {
|
||||
|
||||
/* codec private data */
|
||||
struct wm8741_priv {
|
||||
struct wm8741_platform_data pdata;
|
||||
struct regmap *regmap;
|
||||
struct regulator_bulk_data supplies[WM8741_NUM_SUPPLIES];
|
||||
unsigned int sysclk;
|
||||
@ -87,13 +88,27 @@ static int wm8741_reset(struct snd_soc_codec *codec)
|
||||
static const DECLARE_TLV_DB_SCALE(dac_tlv_fine, -12700, 13, 0);
|
||||
static const DECLARE_TLV_DB_SCALE(dac_tlv, -12700, 400, 0);
|
||||
|
||||
static const struct snd_kcontrol_new wm8741_snd_controls[] = {
|
||||
static const struct snd_kcontrol_new wm8741_snd_controls_stereo[] = {
|
||||
SOC_DOUBLE_R_TLV("Fine Playback Volume", WM8741_DACLLSB_ATTENUATION,
|
||||
WM8741_DACRLSB_ATTENUATION, 1, 255, 1, dac_tlv_fine),
|
||||
SOC_DOUBLE_R_TLV("Playback Volume", WM8741_DACLMSB_ATTENUATION,
|
||||
WM8741_DACRMSB_ATTENUATION, 0, 511, 1, dac_tlv),
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new wm8741_snd_controls_mono_left[] = {
|
||||
SOC_SINGLE_TLV("Fine Playback Volume", WM8741_DACLLSB_ATTENUATION,
|
||||
1, 255, 1, dac_tlv_fine),
|
||||
SOC_SINGLE_TLV("Playback Volume", WM8741_DACLMSB_ATTENUATION,
|
||||
0, 511, 1, dac_tlv),
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new wm8741_snd_controls_mono_right[] = {
|
||||
SOC_SINGLE_TLV("Fine Playback Volume", WM8741_DACRLSB_ATTENUATION,
|
||||
1, 255, 1, dac_tlv_fine),
|
||||
SOC_SINGLE_TLV("Playback Volume", WM8741_DACRMSB_ATTENUATION,
|
||||
0, 511, 1, dac_tlv),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_widget wm8741_dapm_widgets[] = {
|
||||
SND_SOC_DAPM_DAC("DACL", "Playback", SND_SOC_NOPM, 0, 0),
|
||||
SND_SOC_DAPM_DAC("DACR", "Playback", SND_SOC_NOPM, 0, 0),
|
||||
@ -398,7 +413,7 @@ static struct snd_soc_dai_driver wm8741_dai = {
|
||||
.name = "wm8741",
|
||||
.playback = {
|
||||
.stream_name = "Playback",
|
||||
.channels_min = 2, /* Mono modes not yet supported */
|
||||
.channels_min = 2,
|
||||
.channels_max = 2,
|
||||
.rates = WM8741_RATES,
|
||||
.formats = WM8741_FORMATS,
|
||||
@ -416,6 +431,65 @@ static int wm8741_resume(struct snd_soc_codec *codec)
|
||||
#define wm8741_resume NULL
|
||||
#endif
|
||||
|
||||
static int wm8741_configure(struct snd_soc_codec *codec)
|
||||
{
|
||||
struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec);
|
||||
|
||||
/* Configure differential mode */
|
||||
switch (wm8741->pdata.diff_mode) {
|
||||
case WM8741_DIFF_MODE_STEREO:
|
||||
case WM8741_DIFF_MODE_STEREO_REVERSED:
|
||||
case WM8741_DIFF_MODE_MONO_LEFT:
|
||||
case WM8741_DIFF_MODE_MONO_RIGHT:
|
||||
snd_soc_update_bits(codec, WM8741_MODE_CONTROL_2,
|
||||
WM8741_DIFF_MASK,
|
||||
wm8741->pdata.diff_mode << WM8741_DIFF_SHIFT);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Change some default settings - latch VU */
|
||||
snd_soc_update_bits(codec, WM8741_DACLLSB_ATTENUATION,
|
||||
WM8741_UPDATELL, WM8741_UPDATELL);
|
||||
snd_soc_update_bits(codec, WM8741_DACLMSB_ATTENUATION,
|
||||
WM8741_UPDATELM, WM8741_UPDATELM);
|
||||
snd_soc_update_bits(codec, WM8741_DACRLSB_ATTENUATION,
|
||||
WM8741_UPDATERL, WM8741_UPDATERL);
|
||||
snd_soc_update_bits(codec, WM8741_DACRMSB_ATTENUATION,
|
||||
WM8741_UPDATERM, WM8741_UPDATERM);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wm8741_add_controls(struct snd_soc_codec *codec)
|
||||
{
|
||||
struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec);
|
||||
|
||||
switch (wm8741->pdata.diff_mode) {
|
||||
case WM8741_DIFF_MODE_STEREO:
|
||||
case WM8741_DIFF_MODE_STEREO_REVERSED:
|
||||
snd_soc_add_codec_controls(codec,
|
||||
wm8741_snd_controls_stereo,
|
||||
ARRAY_SIZE(wm8741_snd_controls_stereo));
|
||||
break;
|
||||
case WM8741_DIFF_MODE_MONO_LEFT:
|
||||
snd_soc_add_codec_controls(codec,
|
||||
wm8741_snd_controls_mono_left,
|
||||
ARRAY_SIZE(wm8741_snd_controls_mono_left));
|
||||
break;
|
||||
case WM8741_DIFF_MODE_MONO_RIGHT:
|
||||
snd_soc_add_codec_controls(codec,
|
||||
wm8741_snd_controls_mono_right,
|
||||
ARRAY_SIZE(wm8741_snd_controls_mono_right));
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wm8741_probe(struct snd_soc_codec *codec)
|
||||
{
|
||||
struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec);
|
||||
@ -434,15 +508,17 @@ static int wm8741_probe(struct snd_soc_codec *codec)
|
||||
goto err_enable;
|
||||
}
|
||||
|
||||
/* Change some default settings - latch VU */
|
||||
snd_soc_update_bits(codec, WM8741_DACLLSB_ATTENUATION,
|
||||
WM8741_UPDATELL, WM8741_UPDATELL);
|
||||
snd_soc_update_bits(codec, WM8741_DACLMSB_ATTENUATION,
|
||||
WM8741_UPDATELM, WM8741_UPDATELM);
|
||||
snd_soc_update_bits(codec, WM8741_DACRLSB_ATTENUATION,
|
||||
WM8741_UPDATERL, WM8741_UPDATERL);
|
||||
snd_soc_update_bits(codec, WM8741_DACRMSB_ATTENUATION,
|
||||
WM8741_UPDATERM, WM8741_UPDATERM);
|
||||
ret = wm8741_configure(codec);
|
||||
if (ret < 0) {
|
||||
dev_err(codec->dev, "Failed to change default settings\n");
|
||||
goto err_enable;
|
||||
}
|
||||
|
||||
ret = wm8741_add_controls(codec);
|
||||
if (ret < 0) {
|
||||
dev_err(codec->dev, "Failed to add controls\n");
|
||||
goto err_enable;
|
||||
}
|
||||
|
||||
dev_dbg(codec->dev, "Successful registration\n");
|
||||
return ret;
|
||||
@ -467,8 +543,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8741 = {
|
||||
.remove = wm8741_remove,
|
||||
.resume = wm8741_resume,
|
||||
|
||||
.controls = wm8741_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(wm8741_snd_controls),
|
||||
.dapm_widgets = wm8741_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(wm8741_dapm_widgets),
|
||||
.dapm_routes = wm8741_dapm_routes,
|
||||
@ -493,6 +567,23 @@ static const struct regmap_config wm8741_regmap = {
|
||||
.readable_reg = wm8741_readable,
|
||||
};
|
||||
|
||||
static int wm8741_set_pdata(struct device *dev, struct wm8741_priv *wm8741)
|
||||
{
|
||||
const struct wm8741_platform_data *pdata = dev_get_platdata(dev);
|
||||
u32 diff_mode;
|
||||
|
||||
if (dev->of_node) {
|
||||
if (of_property_read_u32(dev->of_node, "diff-mode", &diff_mode)
|
||||
>= 0)
|
||||
wm8741->pdata.diff_mode = diff_mode;
|
||||
} else {
|
||||
if (pdata != NULL)
|
||||
memcpy(&wm8741->pdata, pdata, sizeof(wm8741->pdata));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if IS_ENABLED(CONFIG_I2C)
|
||||
static int wm8741_i2c_probe(struct i2c_client *i2c,
|
||||
const struct i2c_device_id *id)
|
||||
@ -522,6 +613,12 @@ static int wm8741_i2c_probe(struct i2c_client *i2c,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = wm8741_set_pdata(&i2c->dev, wm8741);
|
||||
if (ret != 0) {
|
||||
dev_err(&i2c->dev, "Failed to set pdata: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
i2c_set_clientdata(i2c, wm8741);
|
||||
|
||||
ret = snd_soc_register_codec(&i2c->dev,
|
||||
@ -582,6 +679,12 @@ static int wm8741_spi_probe(struct spi_device *spi)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = wm8741_set_pdata(&spi->dev, wm8741);
|
||||
if (ret != 0) {
|
||||
dev_err(&spi->dev, "Failed to set pdata: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
spi_set_drvdata(spi, wm8741);
|
||||
|
||||
ret = snd_soc_register_codec(&spi->dev,
|
||||
|
@ -194,6 +194,12 @@
|
||||
#define WM8741_DITHER_SHIFT 0 /* DITHER - [1:0] */
|
||||
#define WM8741_DITHER_WIDTH 2 /* DITHER - [1:0] */
|
||||
|
||||
/* DIFF field values */
|
||||
#define WM8741_DIFF_MODE_STEREO 0 /* stereo normal */
|
||||
#define WM8741_DIFF_MODE_STEREO_REVERSED 2 /* stereo reversed */
|
||||
#define WM8741_DIFF_MODE_MONO_LEFT 1 /* mono left */
|
||||
#define WM8741_DIFF_MODE_MONO_RIGHT 3 /* mono right */
|
||||
|
||||
/*
|
||||
* R32 (0x20) - ADDITONAL_CONTROL_1
|
||||
*/
|
||||
@ -208,4 +214,8 @@
|
||||
|
||||
#define WM8741_SYSCLK 0
|
||||
|
||||
struct wm8741_platform_data {
|
||||
u32 diff_mode; /* Differential Output Mode */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -127,6 +127,8 @@ struct wm8960_priv {
|
||||
struct snd_soc_dapm_widget *out3;
|
||||
bool deemph;
|
||||
int playback_fs;
|
||||
int bclk;
|
||||
int sysclk;
|
||||
struct wm8960_data pdata;
|
||||
};
|
||||
|
||||
@ -563,6 +565,72 @@ static struct {
|
||||
{ 8000, 5 },
|
||||
};
|
||||
|
||||
/* Multiply 256 for internal 256 div */
|
||||
static const int dac_divs[] = { 256, 384, 512, 768, 1024, 1408, 1536 };
|
||||
|
||||
/* Multiply 10 to eliminate decimials */
|
||||
static const int bclk_divs[] = {
|
||||
10, 15, 20, 30, 40, 55, 60, 80, 110,
|
||||
120, 160, 220, 240, 320, 320, 320
|
||||
};
|
||||
|
||||
static void wm8960_configure_clocking(struct snd_soc_codec *codec,
|
||||
bool tx, int lrclk)
|
||||
{
|
||||
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
|
||||
u16 iface1 = snd_soc_read(codec, WM8960_IFACE1);
|
||||
u16 iface2 = snd_soc_read(codec, WM8960_IFACE2);
|
||||
u32 sysclk;
|
||||
int i, j;
|
||||
|
||||
if (!(iface1 & (1<<6))) {
|
||||
dev_dbg(codec->dev,
|
||||
"Codec is slave mode, no need to configure clock\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!wm8960->sysclk) {
|
||||
dev_dbg(codec->dev, "No SYSCLK configured\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!wm8960->bclk || !lrclk) {
|
||||
dev_dbg(codec->dev, "No audio clocks configured\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(dac_divs); ++i) {
|
||||
if (wm8960->sysclk == lrclk * dac_divs[i]) {
|
||||
for (j = 0; j < ARRAY_SIZE(bclk_divs); ++j) {
|
||||
sysclk = wm8960->bclk * bclk_divs[j] / 10;
|
||||
if (wm8960->sysclk == sysclk)
|
||||
break;
|
||||
}
|
||||
if(j != ARRAY_SIZE(bclk_divs))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == ARRAY_SIZE(dac_divs)) {
|
||||
dev_err(codec->dev, "Unsupported sysclk %d\n", wm8960->sysclk);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* configure frame clock. If ADCLRC configure as GPIO pin, DACLRC
|
||||
* pin is used as a frame clock for ADCs and DACs.
|
||||
*/
|
||||
if (iface2 & (1<<6))
|
||||
snd_soc_update_bits(codec, WM8960_CLOCK1, 0x7 << 3, i << 3);
|
||||
else if (tx)
|
||||
snd_soc_update_bits(codec, WM8960_CLOCK1, 0x7 << 3, i << 3);
|
||||
else if (!tx)
|
||||
snd_soc_update_bits(codec, WM8960_CLOCK1, 0x7 << 6, i << 6);
|
||||
|
||||
/* configure bit clock */
|
||||
snd_soc_update_bits(codec, WM8960_CLOCK2, 0xf, j);
|
||||
}
|
||||
|
||||
static int wm8960_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params,
|
||||
struct snd_soc_dai *dai)
|
||||
@ -570,8 +638,13 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
|
||||
u16 iface = snd_soc_read(codec, WM8960_IFACE1) & 0xfff3;
|
||||
bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
|
||||
int i;
|
||||
|
||||
wm8960->bclk = snd_soc_params_to_bclk(params);
|
||||
if (params_channels(params) == 1)
|
||||
wm8960->bclk *= 2;
|
||||
|
||||
/* bit size */
|
||||
switch (params_width(params)) {
|
||||
case 16:
|
||||
@ -582,6 +655,12 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream,
|
||||
case 24:
|
||||
iface |= 0x0008;
|
||||
break;
|
||||
case 32:
|
||||
/* right justify mode does not support 32 word length */
|
||||
if ((iface & 0x3) != 0) {
|
||||
iface |= 0x000c;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
dev_err(codec->dev, "unsupported width %d\n",
|
||||
params_width(params));
|
||||
@ -602,6 +681,9 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream,
|
||||
|
||||
/* set iface */
|
||||
snd_soc_write(codec, WM8960_IFACE1, iface);
|
||||
|
||||
wm8960_configure_clocking(codec, tx, params_rate(params));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -946,11 +1028,35 @@ static int wm8960_set_bias_level(struct snd_soc_codec *codec,
|
||||
return wm8960->set_bias_level(codec, level);
|
||||
}
|
||||
|
||||
static int wm8960_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
|
||||
unsigned int freq, int dir)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
|
||||
|
||||
switch (clk_id) {
|
||||
case WM8960_SYSCLK_MCLK:
|
||||
snd_soc_update_bits(codec, WM8960_CLOCK1,
|
||||
0x1, WM8960_SYSCLK_MCLK);
|
||||
break;
|
||||
case WM8960_SYSCLK_PLL:
|
||||
snd_soc_update_bits(codec, WM8960_CLOCK1,
|
||||
0x1, WM8960_SYSCLK_PLL);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
wm8960->sysclk = freq;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define WM8960_RATES SNDRV_PCM_RATE_8000_48000
|
||||
|
||||
#define WM8960_FORMATS \
|
||||
(SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
|
||||
SNDRV_PCM_FMTBIT_S24_LE)
|
||||
SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
|
||||
|
||||
static const struct snd_soc_dai_ops wm8960_dai_ops = {
|
||||
.hw_params = wm8960_hw_params,
|
||||
@ -958,6 +1064,7 @@ static const struct snd_soc_dai_ops wm8960_dai_ops = {
|
||||
.set_fmt = wm8960_set_dai_fmt,
|
||||
.set_clkdiv = wm8960_set_dai_clkdiv,
|
||||
.set_pll = wm8960_set_dai_pll,
|
||||
.set_sysclk = wm8960_set_dai_sysclk,
|
||||
};
|
||||
|
||||
static struct snd_soc_dai_driver wm8960_dai = {
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <sound/pcm_params.h>
|
||||
#include <sound/soc.h>
|
||||
#include <sound/soc-dpcm.h>
|
||||
#include <sound/soc-topology.h>
|
||||
#include <sound/initval.h>
|
||||
|
||||
#define CREATE_TRACE_POINTS
|
||||
@ -2418,6 +2419,7 @@ int snd_soc_register_card(struct snd_soc_card *card)
|
||||
card->rtd_aux[i].card = card;
|
||||
|
||||
INIT_LIST_HEAD(&card->dapm_dirty);
|
||||
INIT_LIST_HEAD(&card->dobj_list);
|
||||
card->instantiated = 0;
|
||||
mutex_init(&card->mutex);
|
||||
mutex_init(&card->dapm_mutex);
|
||||
@ -2733,6 +2735,7 @@ static void snd_soc_component_add_unlocked(struct snd_soc_component *component)
|
||||
}
|
||||
|
||||
list_add(&component->list, &component_list);
|
||||
INIT_LIST_HEAD(&component->dobj_list);
|
||||
}
|
||||
|
||||
static void snd_soc_component_add(struct snd_soc_component *component)
|
||||
@ -2809,6 +2812,7 @@ void snd_soc_unregister_component(struct device *dev)
|
||||
return;
|
||||
|
||||
found:
|
||||
snd_soc_tplg_component_remove(cmpnt, SND_SOC_TPLG_INDEX_ALL);
|
||||
snd_soc_component_del_unlocked(cmpnt);
|
||||
mutex_unlock(&client_mutex);
|
||||
snd_soc_component_cleanup(cmpnt);
|
||||
|
1826
sound/soc/soc-topology.c
Normal file
1826
sound/soc/soc-topology.c
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user