/** * PSC_I2S_RATES: sample rates supported by the I2S * * This driver currently only supports the PSC running in I2S slave mode, * which means the codec determines the sample rate. Therefore, we tell * ALSA that we support all rates and let the codec driver decide what rates * are really supported.
*/ #define PSC_I2S_RATES SNDRV_PCM_RATE_CONTINUOUS
switch (params_format(params)) { case SNDRV_PCM_FORMAT_S8:
mode = MPC52xx_PSC_SICR_SIM_CODEC_8; break; case SNDRV_PCM_FORMAT_S16_BE:
mode = MPC52xx_PSC_SICR_SIM_CODEC_16; break; case SNDRV_PCM_FORMAT_S24_BE:
mode = MPC52xx_PSC_SICR_SIM_CODEC_24; break; case SNDRV_PCM_FORMAT_S32_BE:
mode = MPC52xx_PSC_SICR_SIM_CODEC_32; break; default:
dev_dbg(psc_dma->dev, "invalid format\n"); return -EINVAL;
}
out_be32(&psc_dma->psc_regs->sicr, psc_dma->sicr | mode);
return 0;
}
/** * psc_i2s_set_sysclk: set the clock frequency and direction * * This function is called by the machine driver to tell us what the clock * frequency and direction are. * * Currently, we only support operating as a clock slave (SND_SOC_CLOCK_IN), * and we don't care about the frequency. Return an error if the direction * is not SND_SOC_CLOCK_IN. * * @clk_id: reserved, should be zero * @freq: the frequency of the given clock ID, currently ignored * @dir: SND_SOC_CLOCK_IN (clock slave) or SND_SOC_CLOCK_OUT (clock master)
*/ staticint psc_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, int clk_id, unsignedint freq, int dir)
{ struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(cpu_dai);
dev_dbg(psc_dma->dev, "psc_i2s_set_sysclk(cpu_dai=%p, dir=%i)\n",
cpu_dai, dir); return (dir == SND_SOC_CLOCK_IN) ? 0 : -EINVAL;
}
/** * psc_i2s_set_fmt: set the serial format. * * This function is called by the machine driver to tell us what serial * format to use. * * This driver only supports I2S mode. Return an error if the format is * not SND_SOC_DAIFMT_I2S. * * @format: one of SND_SOC_DAIFMT_xxx
*/ staticint psc_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsignedint format)
{ struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(cpu_dai);
dev_dbg(psc_dma->dev, "psc_i2s_set_fmt(cpu_dai=%p, format=%i)\n",
cpu_dai, format); return (format == SND_SOC_DAIFMT_I2S) ? 0 : -EINVAL;
}
/* --------------------------------------------------------------------- * ALSA SoC Bindings * * - Digital Audio Interface (DAI) template * - create/destroy dai hooks
*/
/* Configure the serial interface mode; defaulting to CODEC8 mode */
psc_dma->sicr = MPC52xx_PSC_SICR_DTS1 | MPC52xx_PSC_SICR_I2S |
MPC52xx_PSC_SICR_CLKPOL;
out_be32(&psc_dma->psc_regs->sicr,
psc_dma->sicr | MPC52xx_PSC_SICR_SIM_CODEC_8);
/* Check for the codec handle. If it is not present then we
* are done */ if (!of_property_present(op->dev.of_node, "codec-handle")) return 0;
/* Due to errata in the dma mode; need to line up enabling * the transmitter with a transition on the frame sync
* line */
/* first make sure it is low */ while ((in_8(®s->ipcr_acr.ipcr) & 0x80) != 0)
; /* then wait for the transition to high */ while ((in_8(®s->ipcr_acr.ipcr) & 0x80) == 0)
; /* Finally, enable the PSC. * Receiver must always be enabled; even when we only want
* transmit. (see 15.3.2.3 of MPC5200B User's Guide) */
/* Go */
out_8(&psc_dma->psc_regs->command,
MPC52xx_PSC_TX_ENABLE | MPC52xx_PSC_RX_ENABLE);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.