Example #1
0
static int snd_stm_conv_i2sspdif_register(struct snd_device *snd_device)
{
	struct snd_stm_conv_i2sspdif *conv_i2sspdif = snd_device->device_data;
	int i;

	snd_stm_printd(1, "%s(snd_device=0x%p)\n", __func__, snd_device);

	BUG_ON(!conv_i2sspdif);
	BUG_ON(!snd_stm_magic_valid(conv_i2sspdif));
	BUG_ON(conv_i2sspdif->enabled);

	/* Initialize converter's input & SPDIF player as disabled */

	set__AUD_SPDIFPC_CFG(conv_i2sspdif,
		mask__AUD_SPDIFPC_CFG__DEVICE_EN__DISABLED(conv_i2sspdif) |
		mask__AUD_SPDIFPC_CFG__SW_RESET__RESET(conv_i2sspdif) |
		mask__AUD_SPDIFPC_CFG__FIFO_EN__DISABLED(conv_i2sspdif) |
		mask__AUD_SPDIFPC_CFG__REQ_ACK_EN__DISABLED(conv_i2sspdif));

	set__AUD_SPDIFPC_CTRL(conv_i2sspdif,
		mask__AUD_SPDIFPC_CTRL__OPERATION__OFF(conv_i2sspdif));

	/* Additional procfs info */

	snd_stm_info_register(&conv_i2sspdif->proc_entry,
			dev_name(conv_i2sspdif->device),
			snd_stm_conv_i2sspdif_dump_registers,
			conv_i2sspdif);

	/* Create ALSA controls */

	for (i = 0; i < ARRAY_SIZE(snd_stm_conv_i2sspdif_ctls); i++) {
		int result;

		snd_stm_conv_i2sspdif_ctls[i].device =
				snd_stm_conv_get_card_device(
				conv_i2sspdif->converter);
		snd_stm_conv_i2sspdif_ctls[i].index = conv_i2sspdif->index;
		result = snd_ctl_add(snd_stm_card_get(),
				snd_ctl_new1(&snd_stm_conv_i2sspdif_ctls[i],
				conv_i2sspdif));
		if (result < 0) {
			snd_stm_printe("Failed to add I2S-SPDIF converter "
					"ALSA control!\n");
			return result;
		}
	}

	return 0;
}
Example #2
0
static int snd_stm_conv_dac_mem_register(struct snd_device *snd_device)
{
	struct snd_stm_conv_dac_mem *conv_dac_mem =
			snd_device->device_data;

	BUG_ON(!conv_dac_mem);
	BUG_ON(!snd_stm_magic_valid(conv_dac_mem));

	/* Initialize DAC with digital part down, analog up and muted */
	writel(NRST__RESET | MODE__DEFAULT | NSB__POWER_DOWN |
			SOFTMUTE__MUTE | PDNANA__NORMAL | PDNBG__NORMAL,
			ADAC_CTRL(conv_dac_mem->base));

	/* Additional procfs info */
	snd_stm_info_register(&conv_dac_mem->proc_entry,
			conv_dac_mem->dev_name,
			snd_stm_conv_dac_mem_read_info,
			conv_dac_mem);

	return 0;
}
Example #3
0
static int snd_stm_pcm_player_register(struct snd_device *snd_device)
{
	struct snd_stm_pcm_player *pcm_player = snd_device->device_data;

	snd_stm_printd(1, "%s(snd_device=0x%p)\n", __func__, snd_device);

	BUG_ON(!pcm_player);
	BUG_ON(!snd_stm_magic_valid(pcm_player));

	/* Set reset mode */

	set__AUD_PCMOUT_RST__SRSTP__RESET(pcm_player);

	/* TODO: well, hardcoded - shall anyone use it?
	 * And what does it actually mean? */

	if (pcm_player->ver > 5)
		set__AUD_PCMOUT_FMT__BACK_STALLING__DISABLED(pcm_player);
	set__AUD_PCMOUT_CTRL__RND__NO_ROUNDING(pcm_player);

	/* Get frequency synthesizer channel */

	pcm_player->clock = snd_stm_clk_get(pcm_player->device,
			"pcm_player_clk", snd_device->card,
			pcm_player->info->card_device);
	if (!pcm_player->clock || IS_ERR(pcm_player->clock)) {
		snd_stm_printe("Failed to get a clock for '%s'!\n",
				dev_name(pcm_player->device));
		return -EINVAL;
	}

	/* Registers view in ALSA's procfs */

	snd_stm_info_register(&pcm_player->proc_entry,
			dev_name(pcm_player->device),
			snd_stm_pcm_player_dump_registers, pcm_player);

	return 0;
}
Example #4
0
static int __init snd_stm_stih415_probe(struct platform_device *pdev)
{
	int result;

	dev_dbg(&pdev->dev, "%s()", __func__);

	if (!stm_soc_is_stih415()) {
		dev_err(&pdev->dev, "Unsupported (not STiH415) SOC detected!");
		return -EINVAL;
	}

	/* Claim external pcm clock sysconf */
	snd_stm_stih415_pcm_clk_sel = sysconf_claim(SYSCONF(331), 8, 11,
						       "PCM_CLK_SEL");
	if (!snd_stm_stih415_pcm_clk_sel) {
		dev_err(&pdev->dev, "Failed to claim PCM_CLK_SEL");
		return -EBUSY;
	}

	/* Claim bi-phase idle value sysconf */
	snd_stm_stih415_biphase_idle_value = sysconf_claim(SYSCONF(331), 7, 7,
						       "BIPHASE_IDLE_VALUE");
	if (!snd_stm_stih415_biphase_idle_value) {
		dev_err(&pdev->dev, "Failed to claim BIPHASE_IDLE_VALUE");
		result = -EBUSY;
		goto error_sysconf_claim_biphase_idle_value;
	}

	/* Claim voip sysconf */
	snd_stm_stih415_voip = sysconf_claim(SYSCONF(331), 2, 5, "VOIP");
	if (!snd_stm_stih415_voip) {
		dev_err(&pdev->dev, "Failed to claim VOIP");
		result = -EBUSY;
		goto error_sysconf_claim_voip;
	}

	/* Claim pcm player routing sysconf */
	snd_stm_stih415_pcmp_valid_sel = sysconf_claim(SYSCONF(331), 0, 1,
						       "PCMP_VALID_SEL");
	if (!snd_stm_stih415_pcmp_valid_sel) {
		dev_err(&pdev->dev, "Failed to claim PCMP_VALID_SEL");
		result = -EBUSY;
		goto error_sysconf_claim_pcmp_valid_sel;
	}

	/* Set the sysconf values */
	snd_stm_stih415_setup();

	/* Register the sound card */
	result = snd_stm_card_register();
	if (result) {
		dev_err(&pdev->dev, "Failed to register ALSA cards!");
		goto error_card_register;
	}

	/* Register a procfs file */
	result = snd_stm_info_register(&snd_stm_stih415_proc_entry,
			dev_name(&pdev->dev), snd_stm_stih415_procfs, NULL);
	if (result) {
		dev_err(&pdev->dev, "Failed to register with procfs");
		goto error_info_register;
	}

	return 0;

error_info_register:
error_card_register:
	sysconf_release(snd_stm_stih415_pcmp_valid_sel);
error_sysconf_claim_pcmp_valid_sel:
	sysconf_release(snd_stm_stih415_voip);
error_sysconf_claim_voip:
	sysconf_release(snd_stm_stih415_biphase_idle_value);
error_sysconf_claim_biphase_idle_value:
	sysconf_release(snd_stm_stih415_pcm_clk_sel);
	return result;
}
Example #5
0
static int __init snd_stm_fli75xx_glue_probe(struct platform_device *pdev)
{
	int result = 0;
	struct snd_stm_fli75xx_glue *fli75xx_glue;
	unsigned int value;

	snd_stm_printd(0, "%s('%s')\n", __func__, dev_name(&pdev->dev));

	fli75xx_glue = kzalloc(sizeof(*fli75xx_glue), GFP_KERNEL);
	if (!fli75xx_glue) {
		snd_stm_printe("Can't allocate memory "
				"for a device description!\n");
		result = -ENOMEM;
		goto error_alloc;
	}
	snd_stm_magic_set(fli75xx_glue);

	result = snd_stm_memory_request(pdev, &fli75xx_glue->mem_region,
			&fli75xx_glue->base);
	if (result < 0) {
		snd_stm_printe("Memory region request failed!\n");
		goto error_memory_request;
	}

	/* Clocking configuration:
	 *
	 * clk_256fs_free_run --> SPDIF clock
	 *
	 * clk_256fs_dec_1 -----> MAIN (LS) clock
	 *
	 *                    ,-> ENCODER clock
	 * clk_256fs_dec_2 --<
	 *                    `-> DAC (HP, AUX) clock
	 */
	value = SPDIF_CLK__CLK_256FS_FREE_RUN;
	value |= MAIN_CLK__CLK_256FS_DEC_1;
	value |= ENC_CLK__CLK_256FS_DEC_2;
	value |= DAC_CLK__CLK_256FS_DEC_2;
	value |= SPDIF_CLK_DIV2_EN__DISABLED;
	value |= SPDIF_IN_PAD_HYST_EN__DISABLED;
	writel(value, AUD_CONFIG_REG1(fli75xx_glue->base));

	value = SPDIF__PLAYER;

	switch (cpu_data->type) {
	case CPU_FLI7510:
	case CPU_FLI7560:
		value |= FLI7510_MAIN_I2S__PCM_PLAYER_0;
		value |= FLI7510_SEC_I2S__PCM_PLAYER_1;
		break;
	case CPU_FLI7520:
	case CPU_FLI7530:
	case CPU_FLI7540:
		value |= FLI7520_MAIN_I2S__PCM_PLAYER_0;
		value |= FLI7520_SEC_I2S__PCM_PLAYER_1;
	default:
		BUG();
	}

	value |= SPDIF_PLAYER_EN__ENABLED;
	writel(value, AUD_CONFIG_REG2(fli75xx_glue->base));

	/* Additional procfs info */
	snd_stm_info_register(&fli75xx_glue->proc_entry, "fli75xx_glue",
			snd_stm_fli75xx_glue_dump_registers, fli75xx_glue);

	platform_set_drvdata(pdev, fli75xx_glue);

	return result;

error_memory_request:
	snd_stm_magic_clear(fli75xx_glue);
	kfree(fli75xx_glue);
error_alloc:
	return result;
}