cs8427.c (85e9ca333d03fbd56b9e123c8456f0d98e20faad) cs8427.c (5e246b850df563224be26f1d409cf66fd6c968df)
1/*
2 * Routines for control of the CS8427 via i2c bus
3 * IEC958 (S/PDIF) receiver & transmitter by Cirrus Logic
4 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by

--- 300 unchanged lines hidden (view full) ---

309 * CS8427 datasheet, otherwise TXDSERIAL will not work.
310 */
311static void snd_cs8427_reset(struct snd_i2c_device *cs8427)
312{
313 struct cs8427 *chip;
314 unsigned long end_time;
315 int data, aes3input = 0;
316
1/*
2 * Routines for control of the CS8427 via i2c bus
3 * IEC958 (S/PDIF) receiver & transmitter by Cirrus Logic
4 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by

--- 300 unchanged lines hidden (view full) ---

309 * CS8427 datasheet, otherwise TXDSERIAL will not work.
310 */
311static void snd_cs8427_reset(struct snd_i2c_device *cs8427)
312{
313 struct cs8427 *chip;
314 unsigned long end_time;
315 int data, aes3input = 0;
316
317 snd_assert(cs8427, return);
317 if (snd_BUG_ON(!cs8427))
318 return;
318 chip = cs8427->private_data;
319 snd_i2c_lock(cs8427->bus);
320 if ((chip->regmap[CS8427_REG_CLOCKSOURCE] & CS8427_RXDAES3INPUT) ==
321 CS8427_RXDAES3INPUT) /* AES3 bit is set */
322 aes3input = 1;
323 chip->regmap[CS8427_REG_CLOCKSOURCE] &= ~(CS8427_RUN | CS8427_RXDMASK);
324 snd_cs8427_reg_write(cs8427, CS8427_REG_CLOCKSOURCE,
325 chip->regmap[CS8427_REG_CLOCKSOURCE]);

--- 195 unchanged lines hidden (view full) ---

521 struct snd_pcm_substream *play_substream,
522 struct snd_pcm_substream *cap_substream)
523{
524 struct cs8427 *chip = cs8427->private_data;
525 struct snd_kcontrol *kctl;
526 unsigned int idx;
527 int err;
528
319 chip = cs8427->private_data;
320 snd_i2c_lock(cs8427->bus);
321 if ((chip->regmap[CS8427_REG_CLOCKSOURCE] & CS8427_RXDAES3INPUT) ==
322 CS8427_RXDAES3INPUT) /* AES3 bit is set */
323 aes3input = 1;
324 chip->regmap[CS8427_REG_CLOCKSOURCE] &= ~(CS8427_RUN | CS8427_RXDMASK);
325 snd_cs8427_reg_write(cs8427, CS8427_REG_CLOCKSOURCE,
326 chip->regmap[CS8427_REG_CLOCKSOURCE]);

--- 195 unchanged lines hidden (view full) ---

522 struct snd_pcm_substream *play_substream,
523 struct snd_pcm_substream *cap_substream)
524{
525 struct cs8427 *chip = cs8427->private_data;
526 struct snd_kcontrol *kctl;
527 unsigned int idx;
528 int err;
529
529 snd_assert(play_substream && cap_substream, return -EINVAL);
530 if (snd_BUG_ON(!play_substream || !cap_substream))
531 return -EINVAL;
530 for (idx = 0; idx < ARRAY_SIZE(snd_cs8427_iec958_controls); idx++) {
531 kctl = snd_ctl_new1(&snd_cs8427_iec958_controls[idx], cs8427);
532 if (kctl == NULL)
533 return -ENOMEM;
534 kctl->id.device = play_substream->pcm->device;
535 kctl->id.subdevice = play_substream->number;
536 err = snd_ctl_add(cs8427->bus->card, kctl);
537 if (err < 0)
538 return err;
539 if (! strcmp(kctl->id.name,
540 SNDRV_CTL_NAME_IEC958("",PLAYBACK,PCM_STREAM)))
541 chip->playback.pcm_ctl = kctl;
542 }
543
544 chip->playback.substream = play_substream;
545 chip->capture.substream = cap_substream;
532 for (idx = 0; idx < ARRAY_SIZE(snd_cs8427_iec958_controls); idx++) {
533 kctl = snd_ctl_new1(&snd_cs8427_iec958_controls[idx], cs8427);
534 if (kctl == NULL)
535 return -ENOMEM;
536 kctl->id.device = play_substream->pcm->device;
537 kctl->id.subdevice = play_substream->number;
538 err = snd_ctl_add(cs8427->bus->card, kctl);
539 if (err < 0)
540 return err;
541 if (! strcmp(kctl->id.name,
542 SNDRV_CTL_NAME_IEC958("",PLAYBACK,PCM_STREAM)))
543 chip->playback.pcm_ctl = kctl;
544 }
545
546 chip->playback.substream = play_substream;
547 chip->capture.substream = cap_substream;
546 snd_assert(chip->playback.pcm_ctl, return -EIO);
548 if (snd_BUG_ON(!chip->playback.pcm_ctl))
549 return -EIO;
547 return 0;
548}
549
550EXPORT_SYMBOL(snd_cs8427_iec958_build);
551
552int snd_cs8427_iec958_active(struct snd_i2c_device *cs8427, int active)
553{
554 struct cs8427 *chip;
555
550 return 0;
551}
552
553EXPORT_SYMBOL(snd_cs8427_iec958_build);
554
555int snd_cs8427_iec958_active(struct snd_i2c_device *cs8427, int active)
556{
557 struct cs8427 *chip;
558
556 snd_assert(cs8427, return -ENXIO);
559 if (snd_BUG_ON(!cs8427))
560 return -ENXIO;
557 chip = cs8427->private_data;
558 if (active)
559 memcpy(chip->playback.pcm_status,
560 chip->playback.def_status, 24);
561 chip->playback.pcm_ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
562 snd_ctl_notify(cs8427->bus->card,
563 SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO,
564 &chip->playback.pcm_ctl->id);
565 return 0;
566}
567
568EXPORT_SYMBOL(snd_cs8427_iec958_active);
569
570int snd_cs8427_iec958_pcm(struct snd_i2c_device *cs8427, unsigned int rate)
571{
572 struct cs8427 *chip;
573 char *status;
574 int err, reset;
575
561 chip = cs8427->private_data;
562 if (active)
563 memcpy(chip->playback.pcm_status,
564 chip->playback.def_status, 24);
565 chip->playback.pcm_ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
566 snd_ctl_notify(cs8427->bus->card,
567 SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO,
568 &chip->playback.pcm_ctl->id);
569 return 0;
570}
571
572EXPORT_SYMBOL(snd_cs8427_iec958_active);
573
574int snd_cs8427_iec958_pcm(struct snd_i2c_device *cs8427, unsigned int rate)
575{
576 struct cs8427 *chip;
577 char *status;
578 int err, reset;
579
576 snd_assert(cs8427, return -ENXIO);
580 if (snd_BUG_ON(!cs8427))
581 return -ENXIO;
577 chip = cs8427->private_data;
578 status = chip->playback.pcm_status;
579 snd_i2c_lock(cs8427->bus);
580 if (status[0] & IEC958_AES0_PROFESSIONAL) {
581 status[0] &= ~IEC958_AES0_PRO_FS;
582 switch (rate) {
583 case 32000: status[0] |= IEC958_AES0_PRO_FS_32000; break;
584 case 44100: status[0] |= IEC958_AES0_PRO_FS_44100; break;

--- 37 unchanged lines hidden ---
582 chip = cs8427->private_data;
583 status = chip->playback.pcm_status;
584 snd_i2c_lock(cs8427->bus);
585 if (status[0] & IEC958_AES0_PROFESSIONAL) {
586 status[0] &= ~IEC958_AES0_PRO_FS;
587 switch (rate) {
588 case 32000: status[0] |= IEC958_AES0_PRO_FS_32000; break;
589 case 44100: status[0] |= IEC958_AES0_PRO_FS_44100; break;

--- 37 unchanged lines hidden ---