Example #1
0
static irqreturn_t
snd_nm256_intr_check(struct nm256 *chip)
{
	if (chip->badintrcount++ > 1000) {
		/*
		 * I'm not sure if the best thing is to stop the card from
		 * playing or just release the interrupt (after all, we're in
		 * a bad situation, so doing fancy stuff may not be such a good
		 * idea).
		 *
		 * I worry about the card engine continuing to play noise
		 * over and over, however--that could become a very
		 * obnoxious problem.  And we know that when this usually
		 * happens things are fairly safe, it just means the user's
		 * inserted a PCMCIA card and someone's spamming us with IRQ 9s.
		 */
		if (chip->streams[SNDRV_PCM_STREAM_PLAYBACK].running)
			snd_nm256_playback_stop(chip);
		if (chip->streams[SNDRV_PCM_STREAM_CAPTURE].running)
			snd_nm256_capture_stop(chip);
		chip->badintrcount = 0;
		return IRQ_HANDLED;
	}
	return IRQ_NONE;
}
Example #2
0
static int
snd_nm256_capture_trigger(struct snd_pcm_substream *substream, int cmd)
{
	struct nm256 *chip = snd_pcm_substream_chip(substream);
	struct nm256_stream *s = substream->runtime->private_data;
	int err = 0;

	if (snd_BUG_ON(!s))
		return -ENXIO;

	spin_lock(&chip->reg_lock);
	switch (cmd) {
	case SNDRV_PCM_TRIGGER_START:
	case SNDRV_PCM_TRIGGER_RESUME:
		if (! s->running) {
			snd_nm256_capture_start(chip, s, substream);
			s->running = 1;
		}
		break;
	case SNDRV_PCM_TRIGGER_STOP:
	case SNDRV_PCM_TRIGGER_SUSPEND:
		if (s->running) {
			snd_nm256_capture_stop(chip);
			s->running = 0;
		}
		break;
	default:
		err = -EINVAL;
		break;
	}
	spin_unlock(&chip->reg_lock);
	return err;
}
Example #3
0
static int snd_nm256_free(nm256_t *chip)
{
    if (chip->streams[SNDRV_PCM_STREAM_PLAYBACK].running)
        snd_nm256_playback_stop(chip);
    if (chip->streams[SNDRV_PCM_STREAM_CAPTURE].running)
        snd_nm256_capture_stop(chip);

    if (chip->irq >= 0)
        synchronize_irq(chip->irq);

    if (chip->cport)
        iounmap(chip->cport);
    if (chip->buffer)
        iounmap(chip->buffer);
    if (chip->res_cport) {
        release_resource(chip->res_cport);
        kfree_nocheck(chip->res_cport);
    }
    if (chip->res_buffer) {
        release_resource(chip->res_buffer);
        kfree_nocheck(chip->res_buffer);
    }
    if (chip->irq >= 0)
        free_irq(chip->irq, (void*)chip);

    pci_disable_device(chip->pci);
    kfree(chip);
    return 0;
}
static irqreturn_t
snd_nm256_intr_check(struct nm256 *chip)
{
	if (chip->badintrcount++ > 1000) {
		if (chip->streams[SNDRV_PCM_STREAM_PLAYBACK].running)
			snd_nm256_playback_stop(chip);
		if (chip->streams[SNDRV_PCM_STREAM_CAPTURE].running)
			snd_nm256_capture_stop(chip);
		chip->badintrcount = 0;
		return IRQ_HANDLED;
	}
	return IRQ_NONE;
}
Example #5
0
static int snd_nm256_free(struct nm256 *chip)
{
	if (chip->streams[SNDRV_PCM_STREAM_PLAYBACK].running)
		snd_nm256_playback_stop(chip);
	if (chip->streams[SNDRV_PCM_STREAM_CAPTURE].running)
		snd_nm256_capture_stop(chip);

	if (chip->irq >= 0)
		free_irq(chip->irq, chip);

	if (chip->cport)
		iounmap(chip->cport);
	if (chip->buffer)
		iounmap(chip->buffer);
	release_and_free_resource(chip->res_cport);
	release_and_free_resource(chip->res_buffer);

	pci_disable_device(chip->pci);
	kfree(chip->ac97_regs);
	kfree(chip);
	return 0;
}