Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 230422
b: refs/heads/master
c: 67c7efa
h: refs/heads/master
v: v3
  • Loading branch information
Mark Brown committed Dec 17, 2010
1 parent b3fcd3a commit 40b935b
Show file tree
Hide file tree
Showing 8 changed files with 316 additions and 189 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 991e02b4469c2e92cc98aa5b04fbde981671b74c
refs/heads/master: 67c7efad9a64e9d58a6259332c344ab433f706eb
43 changes: 25 additions & 18 deletions trunk/include/sound/soc-dapm.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
#define SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols) \
{ .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \
.invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1}
#define SND_SOC_DAPM_VIRT_MUX(wname, wreg, wshift, winvert, wcontrols) \
{ .id = snd_soc_dapm_virt_mux, .name = wname, .reg = wreg, .shift = wshift, \
.invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1}
#define SND_SOC_DAPM_VALUE_MUX(wname, wreg, wshift, winvert, wcontrols) \
{ .id = snd_soc_dapm_value_mux, .name = wname, .reg = wreg, \
.shift = wshift, .invert = winvert, .kcontrols = wcontrols, \
Expand Down Expand Up @@ -148,6 +151,11 @@
{ .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \
.invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \
.event = wevent, .event_flags = wflags}
#define SND_SOC_DAPM_VIRT_MUX_E(wname, wreg, wshift, winvert, wcontrols, \
wevent, wflags) \
{ .id = snd_soc_dapm_virt_mux, .name = wname, .reg = wreg, .shift = wshift, \
.invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \
.event = wevent, .event_flags = wflags}

/* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */
#define SOC_PGA_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \
Expand Down Expand Up @@ -227,29 +235,13 @@
.info = snd_soc_info_volsw, \
.get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
.private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
#define SOC_DAPM_DOUBLE(xname, reg, shift_left, shift_right, max, invert, \
power) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
.info = snd_soc_info_volsw, \
.get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
.private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) |\
((max) << 16) | ((invert) << 24) }
#define SOC_DAPM_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
.info = snd_soc_info_volsw, \
.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
.tlv.p = (tlv_array), \
.get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
.private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
#define SOC_DAPM_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, \
power, tlv_array) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
.tlv.p = (tlv_array), \
.info = snd_soc_info_volsw, \
.get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
.private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) |\
((max) << 16) | ((invert) << 24) }
#define SOC_DAPM_ENUM(xname, xenum) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
.info = snd_soc_info_enum_double, \
Expand Down Expand Up @@ -373,6 +365,7 @@ enum snd_soc_dapm_type {
snd_soc_dapm_input = 0, /* input pin */
snd_soc_dapm_output, /* output pin */
snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */
snd_soc_dapm_virt_mux, /* virtual version of snd_soc_dapm_mux */
snd_soc_dapm_value_mux, /* selects 1 analog signal from many inputs */
snd_soc_dapm_mixer, /* mixes several analog signals together */
snd_soc_dapm_mixer_named_ctl, /* mixer with named controls */
Expand Down Expand Up @@ -476,18 +469,32 @@ struct snd_soc_dapm_widget {
struct list_head power_list;
};

struct snd_soc_dapm_update {
struct snd_soc_dapm_widget *widget;
struct snd_kcontrol *kcontrol;
int reg;
int mask;
int val;
};

/* DAPM context */
struct snd_soc_dapm_context {
struct list_head widgets;
struct list_head paths;
int n_widgets; /* number of widgets in this context */
enum snd_soc_bias_level bias_level;
enum snd_soc_bias_level suspend_bias_level;
struct delayed_work delayed_work;
unsigned int idle_bias_off:1; /* Use BIAS_OFF instead of STANDBY */

struct snd_soc_dapm_update *update;

struct device *dev; /* from parent - for debug */
struct snd_soc_codec *codec; /* parent codec */
struct snd_soc_card *card; /* parent card */

/* used during DAPM updates */
int dev_power;
struct list_head list;

#ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_dapm;
#endif
Expand Down
4 changes: 4 additions & 0 deletions trunk/include/sound/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,10 @@ struct snd_soc_card {
struct list_head platform_dev_list;
struct list_head dai_dev_list;

struct list_head widgets;
struct list_head paths;
struct list_head dapm_list;

#ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_card_root;
struct dentry *debugfs_pop_time;
Expand Down
2 changes: 1 addition & 1 deletion trunk/sound/soc/codecs/tlv320aic3x.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol,

if (snd_soc_test_bits(widget->codec, reg, val_mask, val)) {
/* find dapm widget path assoc with kcontrol */
list_for_each_entry(path, &widget->dapm->paths, list) {
list_for_each_entry(path, &widget->dapm->card->paths, list) {
if (path->kcontrol != kcontrol)
continue;

Expand Down
4 changes: 3 additions & 1 deletion trunk/sound/soc/codecs/wm8960.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,9 @@ static int wm8960_add_widgets(struct snd_soc_codec *codec)
* list each time to find the desired power state do so now
* and save the result.
*/
list_for_each_entry(w, &codec->dapm.widgets, list) {
list_for_each_entry(w, &codec->card->widgets, list) {
if (w->dapm != &codec->dapm)
continue;
if (strcmp(w->name, "LOUT1 PGA") == 0)
wm8960->lout1 = w;
if (strcmp(w->name, "ROUT1 PGA") == 0)
Expand Down
80 changes: 50 additions & 30 deletions trunk/sound/soc/sh/fsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ struct fsi_stream {
int buff_len;
int period_len;
int period_num;

int uerr_num;
int oerr_num;
};

struct fsi_priv {
Expand Down Expand Up @@ -326,17 +329,29 @@ static void fsi_stream_push(struct fsi_priv *fsi,
io->buff_offset = 0;
io->period_len = period_len;
io->period_num = 0;
io->oerr_num = -1; /* ignore 1st err */
io->uerr_num = -1; /* ignore 1st err */
}

static void fsi_stream_pop(struct fsi_priv *fsi, int is_play)
{
struct fsi_stream *io = fsi_get_stream(fsi, is_play);
struct snd_soc_dai *dai = fsi_get_dai(io->substream);


if (io->oerr_num > 0)
dev_err(dai->dev, "over_run = %d\n", io->oerr_num);

if (io->uerr_num > 0)
dev_err(dai->dev, "under_run = %d\n", io->uerr_num);

io->substream = NULL;
io->buff_len = 0;
io->buff_offset = 0;
io->period_len = 0;
io->period_num = 0;
io->oerr_num = 0;
io->uerr_num = 0;
}

static int fsi_get_fifo_data_num(struct fsi_priv *fsi, int is_play)
Expand Down Expand Up @@ -375,6 +390,27 @@ static int fsi_get_frame_width(struct fsi_priv *fsi, int is_play)
return frames_to_bytes(runtime, 1) / io->chan_num;
}

static void fsi_count_fifo_err(struct fsi_priv *fsi)
{
u32 ostatus = fsi_reg_read(fsi, DOFF_ST);
u32 istatus = fsi_reg_read(fsi, DIFF_ST);

if (ostatus & ERR_OVER)
fsi->playback.oerr_num++;

if (ostatus & ERR_UNDER)
fsi->playback.uerr_num++;

if (istatus & ERR_OVER)
fsi->capture.oerr_num++;

if (istatus & ERR_UNDER)
fsi->capture.uerr_num++;

fsi_reg_write(fsi, DOFF_ST, 0);
fsi_reg_write(fsi, DIFF_ST, 0);
}

/*
* dma function
*/
Expand Down Expand Up @@ -574,7 +610,7 @@ static void fsi_soft_all_reset(struct fsi_master *master)
mdelay(10);
}

static int fsi_fifo_data_ctrl(struct fsi_priv *fsi, int startup, int stream)
static int fsi_fifo_data_ctrl(struct fsi_priv *fsi, int stream)
{
struct snd_pcm_runtime *runtime;
struct snd_pcm_substream *substream = NULL;
Expand Down Expand Up @@ -667,40 +703,20 @@ static int fsi_fifo_data_ctrl(struct fsi_priv *fsi, int startup, int stream)
/* update buff_offset */
io->buff_offset += fsi_num2offset(data_num, ch_width);

/* check fifo status */
if (!startup) {
struct snd_soc_dai *dai = fsi_get_dai(substream);
u32 status = is_play ?
fsi_reg_read(fsi, DOFF_ST) :
fsi_reg_read(fsi, DIFF_ST);

if (status & ERR_OVER)
dev_err(dai->dev, "over run\n");
if (status & ERR_UNDER)
dev_err(dai->dev, "under run\n");
}

is_play ?
fsi_reg_write(fsi, DOFF_ST, 0) :
fsi_reg_write(fsi, DIFF_ST, 0);

/* re-enable irq */
fsi_irq_enable(fsi, is_play);

if (over_period)
snd_pcm_period_elapsed(substream);

return 0;
}

static int fsi_data_pop(struct fsi_priv *fsi, int startup)
static int fsi_data_pop(struct fsi_priv *fsi)
{
return fsi_fifo_data_ctrl(fsi, startup, SNDRV_PCM_STREAM_CAPTURE);
return fsi_fifo_data_ctrl(fsi, SNDRV_PCM_STREAM_CAPTURE);
}

static int fsi_data_push(struct fsi_priv *fsi, int startup)
static int fsi_data_push(struct fsi_priv *fsi)
{
return fsi_fifo_data_ctrl(fsi, startup, SNDRV_PCM_STREAM_PLAYBACK);
return fsi_fifo_data_ctrl(fsi, SNDRV_PCM_STREAM_PLAYBACK);
}

static irqreturn_t fsi_interrupt(int irq, void *data)
Expand All @@ -713,13 +729,16 @@ static irqreturn_t fsi_interrupt(int irq, void *data)
fsi_master_mask_set(master, SOFT_RST, IR, IR);

if (int_st & AB_IO(1, AO_SHIFT))
fsi_data_push(&master->fsia, 0);
fsi_data_push(&master->fsia);
if (int_st & AB_IO(1, BO_SHIFT))
fsi_data_push(&master->fsib, 0);
fsi_data_push(&master->fsib);
if (int_st & AB_IO(1, AI_SHIFT))
fsi_data_pop(&master->fsia, 0);
fsi_data_pop(&master->fsia);
if (int_st & AB_IO(1, BI_SHIFT))
fsi_data_pop(&master->fsib, 0);
fsi_data_pop(&master->fsib);

fsi_count_fifo_err(&master->fsia);
fsi_count_fifo_err(&master->fsib);

fsi_irq_clear_status(&master->fsia);
fsi_irq_clear_status(&master->fsib);
Expand Down Expand Up @@ -858,7 +877,8 @@ static int fsi_dai_trigger(struct snd_pcm_substream *substream, int cmd,
fsi_stream_push(fsi, is_play, substream,
frames_to_bytes(runtime, runtime->buffer_size),
frames_to_bytes(runtime, runtime->period_size));
ret = is_play ? fsi_data_push(fsi, 1) : fsi_data_pop(fsi, 1);
ret = is_play ? fsi_data_push(fsi) : fsi_data_pop(fsi);
fsi_irq_enable(fsi, is_play);
break;
case SNDRV_PCM_TRIGGER_STOP:
fsi_irq_disable(fsi, is_play);
Expand Down
6 changes: 4 additions & 2 deletions trunk/sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,7 @@ static int soc_probe_codec(struct snd_soc_card *card,
/* 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 ret;
}
Expand Down Expand Up @@ -1879,6 +1880,9 @@ static int soc_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&card->dai_dev_list);
INIT_LIST_HEAD(&card->codec_dev_list);
INIT_LIST_HEAD(&card->platform_dev_list);
INIT_LIST_HEAD(&card->widgets);
INIT_LIST_HEAD(&card->paths);
INIT_LIST_HEAD(&card->dapm_list);

soc_init_card_debugfs(card);

Expand Down Expand Up @@ -3480,8 +3484,6 @@ int snd_soc_register_codec(struct device *dev,
else
codec->compress_type = SND_SOC_FLAT_COMPRESSION;

INIT_LIST_HEAD(&codec->dapm.widgets);
INIT_LIST_HEAD(&codec->dapm.paths);
codec->write = codec_drv->write;
codec->read = codec_drv->read;
codec->dapm.bias_level = SND_SOC_BIAS_OFF;
Expand Down
Loading

0 comments on commit 40b935b

Please sign in to comment.