/* Open control device */
snd = &card->control;
snd->filp = filp_open(fn_cntl, O_RDWR, 0); if (IS_ERR(snd->filp)) { int ret = PTR_ERR(snd->filp);
ERROR(card, "unable to open sound control device file: %s\n",
fn_cntl);
snd->filp = NULL; return ret;
}
snd->card = card;
/* Open PCM playback device and setup substream */
snd = &card->playback;
snd->filp = filp_open(fn_play, O_WRONLY, 0); if (IS_ERR(snd->filp)) { int ret = PTR_ERR(snd->filp);
/* Open PCM capture device and setup substream */
snd = &card->capture;
snd->filp = filp_open(fn_cap, O_RDONLY, 0); if (IS_ERR(snd->filp)) {
ERROR(card, "No such PCM capture device: %s\n", fn_cap);
snd->substream = NULL;
snd->card = NULL;
snd->filp = NULL;
} else {
pcm_file = snd->filp->private_data;
snd->substream = pcm_file->substream;
snd->card = card;
}
return 0;
}
/* * Close ALSA PCM and control device files
*/ staticint gaudio_close_snd_dev(struct gaudio *gau)
{ struct gaudio_snd_dev *snd;
/* Close control device */
snd = &gau->control; if (snd->filp)
filp_close(snd->filp, NULL);
/* Close PCM playback device and setup substream */
snd = &gau->playback; if (snd->filp)
filp_close(snd->filp, NULL);
/* Close PCM capture device and setup substream */
snd = &gau->capture; if (snd->filp)
filp_close(snd->filp, NULL);
return 0;
}
/* * gaudio_setup - setup ALSA interface and preparing for USB transfer * * This sets up PCM, mixer or MIDI ALSA devices fore USB gadget using. * * Returns negative errno, or zero on success
*/ int gaudio_setup(struct gaudio *card)
{ int ret;
ret = gaudio_open_snd_dev(card); if (ret)
ERROR(card, "we need at least one control device\n");
return ret;
}
/* * gaudio_cleanup - remove ALSA device interface * * This is called to free all resources allocated by @gaudio_setup().
*/ void gaudio_cleanup(struct gaudio *the_card)
{ if (the_card)
gaudio_close_snd_dev(the_card);
}
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.