Exemple #1
0
int snd_ak4114_create(snd_card_t *card,
		      ak4114_read_t *read, ak4114_write_t *write,
		      unsigned char pgm[7], unsigned char txcsb[5],
		      void *private_data, ak4114_t **r_ak4114)
{
	ak4114_t *chip;
	int err = 0;
	unsigned char reg;
	static snd_device_ops_t ops = {
		.dev_free =     snd_ak4114_dev_free,
	};

	chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
	if (chip == NULL)
		return -ENOMEM;
	spin_lock_init(&chip->lock);
	chip->card = card;
	chip->read = read;
	chip->write = write;
	chip->private_data = private_data;

	for (reg = 0; reg < 7; reg++)
		chip->regmap[reg] = pgm[reg];
	for (reg = 0; reg < 5; reg++)
		chip->txcsb[reg] = txcsb[reg];

	chip->workqueue = create_workqueue("snd-ak4114");
	if (chip->workqueue == NULL) {
		kfree(chip);
		return -ENOMEM;
	}

	snd_ak4114_reinit(chip);

	chip->rcs0 = reg_read(chip, AK4114_REG_RCS0) & ~(AK4114_QINT | AK4114_CINT);
	chip->rcs1 = reg_read(chip, AK4114_REG_RCS1);

	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0)
		goto __fail;

	if (r_ak4114)
		*r_ak4114 = chip;
	return 0;

      __fail:
	snd_ak4114_free(chip);
	return err < 0 ? err : -EIO;
}
Exemple #2
0
int snd_ak4114_create(struct snd_card *card,
		      ak4114_read_t *read, ak4114_write_t *write,
		      const unsigned char pgm[7], const unsigned char txcsb[5],
		      void *private_data, struct ak4114 **r_ak4114)
{
	struct ak4114 *chip;
	int err = 0;
	unsigned char reg;
	static struct snd_device_ops ops = {
		.dev_free =     snd_ak4114_dev_free,
	};

	chip = kzalloc(sizeof(*chip), GFP_KERNEL);
	if (chip == NULL)
		return -ENOMEM;
	spin_lock_init(&chip->lock);
	chip->card = card;
	chip->read = read;
	chip->write = write;
	chip->private_data = private_data;
	INIT_DELAYED_WORK(&chip->work, ak4114_stats);

	for (reg = 0; reg < 7; reg++)
		chip->regmap[reg] = pgm[reg];
	for (reg = 0; reg < 5; reg++)
		chip->txcsb[reg] = txcsb[reg];

	ak4114_init_regs(chip);

	chip->rcs0 = reg_read(chip, AK4114_REG_RCS0) & ~(AK4114_QINT | AK4114_CINT);
	chip->rcs1 = reg_read(chip, AK4114_REG_RCS1);

	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0)
		goto __fail;

	if (r_ak4114)
		*r_ak4114 = chip;
	return 0;

      __fail:
	snd_ak4114_free(chip);
	return err < 0 ? err : -EIO;
}
Exemple #3
0
static int snd_ak4114_dev_free(struct snd_device *device)
{
	struct ak4114 *chip = device->device_data;
	snd_ak4114_free(chip);
	return 0;
}
Exemple #4
0
static int snd_ak4114_dev_free(snd_device_t *device)
{
	ak4114_t *chip = device->device_data;
	snd_ak4114_free(chip);
	return 0;
}