int __init snd_cx18_mixer_create(struct snd_cx18_card *cxsc) { struct v4l2_device *v4l2_dev = cxsc->v4l2_dev; struct snd_card *sc = cxsc->sc; int ret; strlcpy(sc->mixername, "CX23418 Mixer", sizeof(sc->mixername)); ret = snd_ctl_add(sc, snd_ctl_new1(snd_cx18_mixer_tv_vol, cxsc)); if (ret) { CX18_ALSA_WARN("%s: failed to add %s control, err %d\n", __func__, snd_cx18_mixer_tv_vol.name, ret); } return ret; }
static int __exit cx18_alsa_exit_callback(struct device *dev, void *data) { struct v4l2_device *v4l2_dev = dev_get_drvdata(dev); struct snd_cx18_card *cxsc; if (v4l2_dev == NULL) { printk(KERN_ERR "cx18-alsa: %s: struct v4l2_device * is NULL\n", __func__); return 0; } cxsc = to_snd_cx18_card(v4l2_dev); if (cxsc == NULL) { CX18_ALSA_WARN("%s: struct snd_cx18_card * is NULL\n", __func__); return 0; } snd_cx18_exit(cxsc); return 0; }
static int snd_cx18_init(struct v4l2_device *v4l2_dev) { struct cx18 *cx = to_cx18(v4l2_dev); struct snd_card *sc = NULL; struct snd_cx18_card *cxsc; int ret; /* Numbrs steps from "Writing an ALSA Driver" by Takashi Iwai */ /* (1) Check and increment the device index */ /* This is a no-op for us. We'll use the cx->instance */ /* (2) Create a card instance */ ret = snd_card_create(SNDRV_DEFAULT_IDX1, /* use first available id */ SNDRV_DEFAULT_STR1, /* xid from end of shortname*/ THIS_MODULE, 0, &sc); if (ret) { CX18_ALSA_ERR("%s: snd_card_create() failed with err %d\n", __func__, ret); goto err_exit; } /* (3) Create a main component */ ret = snd_cx18_card_create(v4l2_dev, sc, &cxsc); if (ret) { CX18_ALSA_ERR("%s: snd_cx18_card_create() failed with err %d\n", __func__, ret); goto err_exit_free; } /* (4) Set the driver ID and name strings */ snd_cx18_card_set_names(cxsc); #if 0 /* (5) Create other components: mixer, PCM, & proc files */ ret = snd_cx18_mixer_create(cxsc); if (ret) { CX18_ALSA_WARN("%s: snd_cx18_mixer_create() failed with err %d:" "proceeding anyway\n", __func__, ret); } #endif ret = snd_cx18_pcm_create(cxsc); if (ret) { CX18_ALSA_ERR("%s: snd_cx18_pcm_create() failed with err %d\n", __func__, ret); goto err_exit_free; } /* FIXME - proc files */ /* (7) Set the driver data and return 0 */ /* We do this out of normal order for PCI drivers to avoid races */ cx->alsa = cxsc; /* (6) Register the card instance */ ret = snd_card_register(sc); if (ret) { cx->alsa = NULL; CX18_ALSA_ERR("%s: snd_card_register() failed with err %d\n", __func__, ret); goto err_exit_free; } return 0; err_exit_free: if (sc != NULL) snd_card_free(sc); err_exit: return ret; }