diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-01-03 06:09:56 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-01-03 06:09:56 -0500 |
commit | 46e67acd5d4cacda758e871eebd15cef4e2c2665 (patch) | |
tree | 80fc9c755da220725b26e76c522a0c9414b11abf /drivers/media | |
parent | f23b7952d37c69c0caa6c8dfb85dbf2eb9e5fcaa (diff) |
[media] wm8775: Revert changeset fcb9757333 to avoid a regression
It seems that cx88 and ivtv use wm8775 on some different modes. The
patch that added support for a board with wm8775 broke ivtv boards with
this device. As we're too close to release 2.6.37, let's just revert
it.
Reported-by: Andy Walls <awalls@md.metrocast.net>
Reported-by: Eric Sharkey <eric@lisaneric.org>
Reported-by: Auric <auric@aanet.com.au>
Reported by: David Gesswein <djg@pdp8online.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/cx88/cx88-alsa.c | 99 | ||||
-rw-r--r-- | drivers/media/video/cx88/cx88-cards.c | 7 | ||||
-rw-r--r-- | drivers/media/video/cx88/cx88-video.c | 27 | ||||
-rw-r--r-- | drivers/media/video/cx88/cx88.h | 6 | ||||
-rw-r--r-- | drivers/media/video/wm8775.c | 104 |
5 files changed, 61 insertions, 182 deletions
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c index 4aaa47c0eabf..54b7fcd469a8 100644 --- a/drivers/media/video/cx88/cx88-alsa.c +++ b/drivers/media/video/cx88/cx88-alsa.c | |||
@@ -40,7 +40,6 @@ | |||
40 | #include <sound/control.h> | 40 | #include <sound/control.h> |
41 | #include <sound/initval.h> | 41 | #include <sound/initval.h> |
42 | #include <sound/tlv.h> | 42 | #include <sound/tlv.h> |
43 | #include <media/wm8775.h> | ||
44 | 43 | ||
45 | #include "cx88.h" | 44 | #include "cx88.h" |
46 | #include "cx88-reg.h" | 45 | #include "cx88-reg.h" |
@@ -587,47 +586,26 @@ static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol, | |||
587 | int left, right, v, b; | 586 | int left, right, v, b; |
588 | int changed = 0; | 587 | int changed = 0; |
589 | u32 old; | 588 | u32 old; |
590 | struct v4l2_control client_ctl; | ||
591 | |||
592 | /* Pass volume & balance onto any WM8775 */ | ||
593 | if (value->value.integer.value[0] >= value->value.integer.value[1]) { | ||
594 | v = value->value.integer.value[0] << 10; | ||
595 | b = value->value.integer.value[0] ? | ||
596 | (0x8000 * value->value.integer.value[1]) / value->value.integer.value[0] : | ||
597 | 0x8000; | ||
598 | } else { | ||
599 | v = value->value.integer.value[1] << 10; | ||
600 | b = value->value.integer.value[1] ? | ||
601 | 0xffff - (0x8000 * value->value.integer.value[0]) / value->value.integer.value[1] : | ||
602 | 0x8000; | ||
603 | } | ||
604 | client_ctl.value = v; | ||
605 | client_ctl.id = V4L2_CID_AUDIO_VOLUME; | ||
606 | call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl); | ||
607 | |||
608 | client_ctl.value = b; | ||
609 | client_ctl.id = V4L2_CID_AUDIO_BALANCE; | ||
610 | call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl); | ||
611 | 589 | ||
612 | left = value->value.integer.value[0] & 0x3f; | 590 | left = value->value.integer.value[0] & 0x3f; |
613 | right = value->value.integer.value[1] & 0x3f; | 591 | right = value->value.integer.value[1] & 0x3f; |
614 | b = right - left; | 592 | b = right - left; |
615 | if (b < 0) { | 593 | if (b < 0) { |
616 | v = 0x3f - left; | 594 | v = 0x3f - left; |
617 | b = (-b) | 0x40; | 595 | b = (-b) | 0x40; |
618 | } else { | 596 | } else { |
619 | v = 0x3f - right; | 597 | v = 0x3f - right; |
620 | } | 598 | } |
621 | /* Do we really know this will always be called with IRQs on? */ | 599 | /* Do we really know this will always be called with IRQs on? */ |
622 | spin_lock_irq(&chip->reg_lock); | 600 | spin_lock_irq(&chip->reg_lock); |
623 | old = cx_read(AUD_VOL_CTL); | 601 | old = cx_read(AUD_VOL_CTL); |
624 | if (v != (old & 0x3f)) { | 602 | if (v != (old & 0x3f)) { |
625 | cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, (old & ~0x3f) | v); | 603 | cx_write(AUD_VOL_CTL, (old & ~0x3f) | v); |
626 | changed = 1; | 604 | changed = 1; |
627 | } | 605 | } |
628 | if ((cx_read(AUD_BAL_CTL) & 0x7f) != b) { | 606 | if (cx_read(AUD_BAL_CTL) != b) { |
629 | cx_write(AUD_BAL_CTL, b); | 607 | cx_write(AUD_BAL_CTL, b); |
630 | changed = 1; | 608 | changed = 1; |
631 | } | 609 | } |
632 | spin_unlock_irq(&chip->reg_lock); | 610 | spin_unlock_irq(&chip->reg_lock); |
633 | 611 | ||
@@ -640,7 +618,7 @@ static const struct snd_kcontrol_new snd_cx88_volume = { | |||
640 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 618 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
641 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | 619 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | |
642 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, | 620 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, |
643 | .name = "Analog-TV Volume", | 621 | .name = "Playback Volume", |
644 | .info = snd_cx88_volume_info, | 622 | .info = snd_cx88_volume_info, |
645 | .get = snd_cx88_volume_get, | 623 | .get = snd_cx88_volume_get, |
646 | .put = snd_cx88_volume_put, | 624 | .put = snd_cx88_volume_put, |
@@ -671,14 +649,7 @@ static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol, | |||
671 | vol = cx_read(AUD_VOL_CTL); | 649 | vol = cx_read(AUD_VOL_CTL); |
672 | if (value->value.integer.value[0] != !(vol & bit)) { | 650 | if (value->value.integer.value[0] != !(vol & bit)) { |
673 | vol ^= bit; | 651 | vol ^= bit; |
674 | cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, vol); | 652 | cx_write(AUD_VOL_CTL, vol); |
675 | /* Pass mute onto any WM8775 */ | ||
676 | if ((1<<6) == bit) { | ||
677 | struct v4l2_control client_ctl; | ||
678 | client_ctl.value = 0 != (vol & bit); | ||
679 | client_ctl.id = V4L2_CID_AUDIO_MUTE; | ||
680 | call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl); | ||
681 | } | ||
682 | ret = 1; | 653 | ret = 1; |
683 | } | 654 | } |
684 | spin_unlock_irq(&chip->reg_lock); | 655 | spin_unlock_irq(&chip->reg_lock); |
@@ -687,7 +658,7 @@ static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol, | |||
687 | 658 | ||
688 | static const struct snd_kcontrol_new snd_cx88_dac_switch = { | 659 | static const struct snd_kcontrol_new snd_cx88_dac_switch = { |
689 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 660 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
690 | .name = "Audio-Out Switch", | 661 | .name = "Playback Switch", |
691 | .info = snd_ctl_boolean_mono_info, | 662 | .info = snd_ctl_boolean_mono_info, |
692 | .get = snd_cx88_switch_get, | 663 | .get = snd_cx88_switch_get, |
693 | .put = snd_cx88_switch_put, | 664 | .put = snd_cx88_switch_put, |
@@ -696,49 +667,13 @@ static const struct snd_kcontrol_new snd_cx88_dac_switch = { | |||
696 | 667 | ||
697 | static const struct snd_kcontrol_new snd_cx88_source_switch = { | 668 | static const struct snd_kcontrol_new snd_cx88_source_switch = { |
698 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 669 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
699 | .name = "Analog-TV Switch", | 670 | .name = "Capture Switch", |
700 | .info = snd_ctl_boolean_mono_info, | 671 | .info = snd_ctl_boolean_mono_info, |
701 | .get = snd_cx88_switch_get, | 672 | .get = snd_cx88_switch_get, |
702 | .put = snd_cx88_switch_put, | 673 | .put = snd_cx88_switch_put, |
703 | .private_value = (1<<6), | 674 | .private_value = (1<<6), |
704 | }; | 675 | }; |
705 | 676 | ||
706 | static int snd_cx88_alc_get(struct snd_kcontrol *kcontrol, | ||
707 | struct snd_ctl_elem_value *value) | ||
708 | { | ||
709 | snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); | ||
710 | struct cx88_core *core = chip->core; | ||
711 | struct v4l2_control client_ctl; | ||
712 | |||
713 | client_ctl.id = V4L2_CID_AUDIO_LOUDNESS; | ||
714 | call_hw(core, WM8775_GID, core, g_ctrl, &client_ctl); | ||
715 | value->value.integer.value[0] = client_ctl.value ? 1 : 0; | ||
716 | |||
717 | return 0; | ||
718 | } | ||
719 | |||
720 | static int snd_cx88_alc_put(struct snd_kcontrol *kcontrol, | ||
721 | struct snd_ctl_elem_value *value) | ||
722 | { | ||
723 | snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); | ||
724 | struct cx88_core *core = chip->core; | ||
725 | struct v4l2_control client_ctl; | ||
726 | |||
727 | client_ctl.value = 0 != value->value.integer.value[0]; | ||
728 | client_ctl.id = V4L2_CID_AUDIO_LOUDNESS; | ||
729 | call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl); | ||
730 | |||
731 | return 0; | ||
732 | } | ||
733 | |||
734 | static struct snd_kcontrol_new snd_cx88_alc_switch = { | ||
735 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
736 | .name = "Line-In ALC Switch", | ||
737 | .info = snd_ctl_boolean_mono_info, | ||
738 | .get = snd_cx88_alc_get, | ||
739 | .put = snd_cx88_alc_put, | ||
740 | }; | ||
741 | |||
742 | /**************************************************************************** | 677 | /**************************************************************************** |
743 | Basic Flow for Sound Devices | 678 | Basic Flow for Sound Devices |
744 | ****************************************************************************/ | 679 | ****************************************************************************/ |
@@ -860,7 +795,6 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci, | |||
860 | { | 795 | { |
861 | struct snd_card *card; | 796 | struct snd_card *card; |
862 | snd_cx88_card_t *chip; | 797 | snd_cx88_card_t *chip; |
863 | struct v4l2_subdev *sd; | ||
864 | int err; | 798 | int err; |
865 | 799 | ||
866 | if (devno >= SNDRV_CARDS) | 800 | if (devno >= SNDRV_CARDS) |
@@ -896,15 +830,6 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci, | |||
896 | if (err < 0) | 830 | if (err < 0) |
897 | goto error; | 831 | goto error; |
898 | 832 | ||
899 | /* If there's a wm8775 then add a Line-In ALC switch */ | ||
900 | list_for_each_entry(sd, &chip->core->v4l2_dev.subdevs, list) { | ||
901 | if (WM8775_GID == sd->grp_id) { | ||
902 | snd_ctl_add(card, snd_ctl_new1(&snd_cx88_alc_switch, | ||
903 | chip)); | ||
904 | break; | ||
905 | } | ||
906 | } | ||
907 | |||
908 | strcpy (card->driver, "CX88x"); | 833 | strcpy (card->driver, "CX88x"); |
909 | sprintf(card->shortname, "Conexant CX%x", pci->device); | 834 | sprintf(card->shortname, "Conexant CX%x", pci->device); |
910 | sprintf(card->longname, "%s at %#llx", | 835 | sprintf(card->longname, "%s at %#llx", |
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c index 9b9e169cce90..0ccc2afd7266 100644 --- a/drivers/media/video/cx88/cx88-cards.c +++ b/drivers/media/video/cx88/cx88-cards.c | |||
@@ -1007,15 +1007,22 @@ static const struct cx88_board cx88_boards[] = { | |||
1007 | .radio_type = UNSET, | 1007 | .radio_type = UNSET, |
1008 | .tuner_addr = ADDR_UNSET, | 1008 | .tuner_addr = ADDR_UNSET, |
1009 | .radio_addr = ADDR_UNSET, | 1009 | .radio_addr = ADDR_UNSET, |
1010 | .audio_chip = V4L2_IDENT_WM8775, | ||
1010 | .input = {{ | 1011 | .input = {{ |
1011 | .type = CX88_VMUX_DVB, | 1012 | .type = CX88_VMUX_DVB, |
1012 | .vmux = 0, | 1013 | .vmux = 0, |
1014 | /* 2: Line-In */ | ||
1015 | .audioroute = 2, | ||
1013 | },{ | 1016 | },{ |
1014 | .type = CX88_VMUX_COMPOSITE1, | 1017 | .type = CX88_VMUX_COMPOSITE1, |
1015 | .vmux = 1, | 1018 | .vmux = 1, |
1019 | /* 2: Line-In */ | ||
1020 | .audioroute = 2, | ||
1016 | },{ | 1021 | },{ |
1017 | .type = CX88_VMUX_SVIDEO, | 1022 | .type = CX88_VMUX_SVIDEO, |
1018 | .vmux = 2, | 1023 | .vmux = 2, |
1024 | /* 2: Line-In */ | ||
1025 | .audioroute = 2, | ||
1019 | }}, | 1026 | }}, |
1020 | .mpeg = CX88_MPEG_DVB, | 1027 | .mpeg = CX88_MPEG_DVB, |
1021 | }, | 1028 | }, |
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index 62cea9549404..d9249e5a04c9 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c | |||
@@ -40,7 +40,6 @@ | |||
40 | #include "cx88.h" | 40 | #include "cx88.h" |
41 | #include <media/v4l2-common.h> | 41 | #include <media/v4l2-common.h> |
42 | #include <media/v4l2-ioctl.h> | 42 | #include <media/v4l2-ioctl.h> |
43 | #include <media/wm8775.h> | ||
44 | 43 | ||
45 | MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards"); | 44 | MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards"); |
46 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); | 45 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); |
@@ -977,7 +976,6 @@ int cx88_set_control(struct cx88_core *core, struct v4l2_control *ctl) | |||
977 | const struct cx88_ctrl *c = NULL; | 976 | const struct cx88_ctrl *c = NULL; |
978 | u32 value,mask; | 977 | u32 value,mask; |
979 | int i; | 978 | int i; |
980 | struct v4l2_control client_ctl; | ||
981 | 979 | ||
982 | for (i = 0; i < CX8800_CTLS; i++) { | 980 | for (i = 0; i < CX8800_CTLS; i++) { |
983 | if (cx8800_ctls[i].v.id == ctl->id) { | 981 | if (cx8800_ctls[i].v.id == ctl->id) { |
@@ -991,27 +989,6 @@ int cx88_set_control(struct cx88_core *core, struct v4l2_control *ctl) | |||
991 | ctl->value = c->v.minimum; | 989 | ctl->value = c->v.minimum; |
992 | if (ctl->value > c->v.maximum) | 990 | if (ctl->value > c->v.maximum) |
993 | ctl->value = c->v.maximum; | 991 | ctl->value = c->v.maximum; |
994 | |||
995 | /* Pass changes onto any WM8775 */ | ||
996 | client_ctl.id = ctl->id; | ||
997 | switch (ctl->id) { | ||
998 | case V4L2_CID_AUDIO_MUTE: | ||
999 | client_ctl.value = ctl->value; | ||
1000 | break; | ||
1001 | case V4L2_CID_AUDIO_VOLUME: | ||
1002 | client_ctl.value = (ctl->value) ? | ||
1003 | (0x90 + ctl->value) << 8 : 0; | ||
1004 | break; | ||
1005 | case V4L2_CID_AUDIO_BALANCE: | ||
1006 | client_ctl.value = ctl->value << 9; | ||
1007 | break; | ||
1008 | default: | ||
1009 | client_ctl.id = 0; | ||
1010 | break; | ||
1011 | } | ||
1012 | if (client_ctl.id) | ||
1013 | call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl); | ||
1014 | |||
1015 | mask=c->mask; | 992 | mask=c->mask; |
1016 | switch (ctl->id) { | 993 | switch (ctl->id) { |
1017 | case V4L2_CID_AUDIO_BALANCE: | 994 | case V4L2_CID_AUDIO_BALANCE: |
@@ -1558,9 +1535,7 @@ static int radio_queryctrl (struct file *file, void *priv, | |||
1558 | if (c->id < V4L2_CID_BASE || | 1535 | if (c->id < V4L2_CID_BASE || |
1559 | c->id >= V4L2_CID_LASTP1) | 1536 | c->id >= V4L2_CID_LASTP1) |
1560 | return -EINVAL; | 1537 | return -EINVAL; |
1561 | if (c->id == V4L2_CID_AUDIO_MUTE || | 1538 | if (c->id == V4L2_CID_AUDIO_MUTE) { |
1562 | c->id == V4L2_CID_AUDIO_VOLUME || | ||
1563 | c->id == V4L2_CID_AUDIO_BALANCE) { | ||
1564 | for (i = 0; i < CX8800_CTLS; i++) { | 1539 | for (i = 0; i < CX8800_CTLS; i++) { |
1565 | if (cx8800_ctls[i].v.id == c->id) | 1540 | if (cx8800_ctls[i].v.id == c->id) |
1566 | break; | 1541 | break; |
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index e8c732e7ae4f..c9981e77416a 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h | |||
@@ -398,19 +398,17 @@ static inline struct cx88_core *to_core(struct v4l2_device *v4l2_dev) | |||
398 | return container_of(v4l2_dev, struct cx88_core, v4l2_dev); | 398 | return container_of(v4l2_dev, struct cx88_core, v4l2_dev); |
399 | } | 399 | } |
400 | 400 | ||
401 | #define call_hw(core, grpid, o, f, args...) \ | 401 | #define call_all(core, o, f, args...) \ |
402 | do { \ | 402 | do { \ |
403 | if (!core->i2c_rc) { \ | 403 | if (!core->i2c_rc) { \ |
404 | if (core->gate_ctrl) \ | 404 | if (core->gate_ctrl) \ |
405 | core->gate_ctrl(core, 1); \ | 405 | core->gate_ctrl(core, 1); \ |
406 | v4l2_device_call_all(&core->v4l2_dev, grpid, o, f, ##args); \ | 406 | v4l2_device_call_all(&core->v4l2_dev, 0, o, f, ##args); \ |
407 | if (core->gate_ctrl) \ | 407 | if (core->gate_ctrl) \ |
408 | core->gate_ctrl(core, 0); \ | 408 | core->gate_ctrl(core, 0); \ |
409 | } \ | 409 | } \ |
410 | } while (0) | 410 | } while (0) |
411 | 411 | ||
412 | #define call_all(core, o, f, args...) call_hw(core, 0, o, f, ##args) | ||
413 | |||
414 | struct cx8800_dev; | 412 | struct cx8800_dev; |
415 | struct cx8802_dev; | 413 | struct cx8802_dev; |
416 | 414 | ||
diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c index 135525649086..fe8ef6419f83 100644 --- a/drivers/media/video/wm8775.c +++ b/drivers/media/video/wm8775.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <media/v4l2-device.h> | 35 | #include <media/v4l2-device.h> |
36 | #include <media/v4l2-chip-ident.h> | 36 | #include <media/v4l2-chip-ident.h> |
37 | #include <media/v4l2-ctrls.h> | 37 | #include <media/v4l2-ctrls.h> |
38 | #include <media/wm8775.h> | ||
39 | 38 | ||
40 | MODULE_DESCRIPTION("wm8775 driver"); | 39 | MODULE_DESCRIPTION("wm8775 driver"); |
41 | MODULE_AUTHOR("Ulf Eklund, Hans Verkuil"); | 40 | MODULE_AUTHOR("Ulf Eklund, Hans Verkuil"); |
@@ -51,16 +50,10 @@ enum { | |||
51 | TOT_REGS | 50 | TOT_REGS |
52 | }; | 51 | }; |
53 | 52 | ||
54 | #define ALC_HOLD 0x85 /* R17: use zero cross detection, ALC hold time 42.6 ms */ | ||
55 | #define ALC_EN 0x100 /* R17: ALC enable */ | ||
56 | |||
57 | struct wm8775_state { | 53 | struct wm8775_state { |
58 | struct v4l2_subdev sd; | 54 | struct v4l2_subdev sd; |
59 | struct v4l2_ctrl_handler hdl; | 55 | struct v4l2_ctrl_handler hdl; |
60 | struct v4l2_ctrl *mute; | 56 | struct v4l2_ctrl *mute; |
61 | struct v4l2_ctrl *vol; | ||
62 | struct v4l2_ctrl *bal; | ||
63 | struct v4l2_ctrl *loud; | ||
64 | u8 input; /* Last selected input (0-0xf) */ | 57 | u8 input; /* Last selected input (0-0xf) */ |
65 | }; | 58 | }; |
66 | 59 | ||
@@ -92,30 +85,6 @@ static int wm8775_write(struct v4l2_subdev *sd, int reg, u16 val) | |||
92 | return -1; | 85 | return -1; |
93 | } | 86 | } |
94 | 87 | ||
95 | static void wm8775_set_audio(struct v4l2_subdev *sd, int quietly) | ||
96 | { | ||
97 | struct wm8775_state *state = to_state(sd); | ||
98 | u8 vol_l, vol_r; | ||
99 | int muted = 0 != state->mute->val; | ||
100 | u16 volume = (u16)state->vol->val; | ||
101 | u16 balance = (u16)state->bal->val; | ||
102 | |||
103 | /* normalize ( 65535 to 0 -> 255 to 0 (+24dB to -103dB) ) */ | ||
104 | vol_l = (min(65536 - balance, 32768) * volume) >> 23; | ||
105 | vol_r = (min(balance, (u16)32768) * volume) >> 23; | ||
106 | |||
107 | /* Mute */ | ||
108 | if (muted || quietly) | ||
109 | wm8775_write(sd, R21, 0x0c0 | state->input); | ||
110 | |||
111 | wm8775_write(sd, R14, vol_l | 0x100); /* 0x100= Left channel ADC zero cross enable */ | ||
112 | wm8775_write(sd, R15, vol_r | 0x100); /* 0x100= Right channel ADC zero cross enable */ | ||
113 | |||
114 | /* Un-mute */ | ||
115 | if (!muted) | ||
116 | wm8775_write(sd, R21, state->input); | ||
117 | } | ||
118 | |||
119 | static int wm8775_s_routing(struct v4l2_subdev *sd, | 88 | static int wm8775_s_routing(struct v4l2_subdev *sd, |
120 | u32 input, u32 output, u32 config) | 89 | u32 input, u32 output, u32 config) |
121 | { | 90 | { |
@@ -133,26 +102,25 @@ static int wm8775_s_routing(struct v4l2_subdev *sd, | |||
133 | state->input = input; | 102 | state->input = input; |
134 | if (!v4l2_ctrl_g_ctrl(state->mute)) | 103 | if (!v4l2_ctrl_g_ctrl(state->mute)) |
135 | return 0; | 104 | return 0; |
136 | if (!v4l2_ctrl_g_ctrl(state->vol)) | 105 | wm8775_write(sd, R21, 0x0c0); |
137 | return 0; | 106 | wm8775_write(sd, R14, 0x1d4); |
138 | if (!v4l2_ctrl_g_ctrl(state->bal)) | 107 | wm8775_write(sd, R15, 0x1d4); |
139 | return 0; | 108 | wm8775_write(sd, R21, 0x100 + state->input); |
140 | wm8775_set_audio(sd, 1); | ||
141 | return 0; | 109 | return 0; |
142 | } | 110 | } |
143 | 111 | ||
144 | static int wm8775_s_ctrl(struct v4l2_ctrl *ctrl) | 112 | static int wm8775_s_ctrl(struct v4l2_ctrl *ctrl) |
145 | { | 113 | { |
146 | struct v4l2_subdev *sd = to_sd(ctrl); | 114 | struct v4l2_subdev *sd = to_sd(ctrl); |
115 | struct wm8775_state *state = to_state(sd); | ||
147 | 116 | ||
148 | switch (ctrl->id) { | 117 | switch (ctrl->id) { |
149 | case V4L2_CID_AUDIO_MUTE: | 118 | case V4L2_CID_AUDIO_MUTE: |
150 | case V4L2_CID_AUDIO_VOLUME: | 119 | wm8775_write(sd, R21, 0x0c0); |
151 | case V4L2_CID_AUDIO_BALANCE: | 120 | wm8775_write(sd, R14, 0x1d4); |
152 | wm8775_set_audio(sd, 0); | 121 | wm8775_write(sd, R15, 0x1d4); |
153 | return 0; | 122 | if (!ctrl->val) |
154 | case V4L2_CID_AUDIO_LOUDNESS: | 123 | wm8775_write(sd, R21, 0x100 + state->input); |
155 | wm8775_write(sd, R17, (ctrl->val ? ALC_EN : 0) | ALC_HOLD); | ||
156 | return 0; | 124 | return 0; |
157 | } | 125 | } |
158 | return -EINVAL; | 126 | return -EINVAL; |
@@ -176,7 +144,16 @@ static int wm8775_log_status(struct v4l2_subdev *sd) | |||
176 | 144 | ||
177 | static int wm8775_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *freq) | 145 | static int wm8775_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *freq) |
178 | { | 146 | { |
179 | wm8775_set_audio(sd, 0); | 147 | struct wm8775_state *state = to_state(sd); |
148 | |||
149 | /* If I remove this, then it can happen that I have no | ||
150 | sound the first time I tune from static to a valid channel. | ||
151 | It's difficult to reproduce and is almost certainly related | ||
152 | to the zero cross detect circuit. */ | ||
153 | wm8775_write(sd, R21, 0x0c0); | ||
154 | wm8775_write(sd, R14, 0x1d4); | ||
155 | wm8775_write(sd, R15, 0x1d4); | ||
156 | wm8775_write(sd, R21, 0x100 + state->input); | ||
180 | return 0; | 157 | return 0; |
181 | } | 158 | } |
182 | 159 | ||
@@ -226,7 +203,6 @@ static int wm8775_probe(struct i2c_client *client, | |||
226 | { | 203 | { |
227 | struct wm8775_state *state; | 204 | struct wm8775_state *state; |
228 | struct v4l2_subdev *sd; | 205 | struct v4l2_subdev *sd; |
229 | int err; | ||
230 | 206 | ||
231 | /* Check if the adapter supports the needed features */ | 207 | /* Check if the adapter supports the needed features */ |
232 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 208 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
@@ -240,21 +216,15 @@ static int wm8775_probe(struct i2c_client *client, | |||
240 | return -ENOMEM; | 216 | return -ENOMEM; |
241 | sd = &state->sd; | 217 | sd = &state->sd; |
242 | v4l2_i2c_subdev_init(sd, client, &wm8775_ops); | 218 | v4l2_i2c_subdev_init(sd, client, &wm8775_ops); |
243 | sd->grp_id = WM8775_GID; /* subdev group id */ | ||
244 | state->input = 2; | 219 | state->input = 2; |
245 | 220 | ||
246 | v4l2_ctrl_handler_init(&state->hdl, 4); | 221 | v4l2_ctrl_handler_init(&state->hdl, 1); |
247 | state->mute = v4l2_ctrl_new_std(&state->hdl, &wm8775_ctrl_ops, | 222 | state->mute = v4l2_ctrl_new_std(&state->hdl, &wm8775_ctrl_ops, |
248 | V4L2_CID_AUDIO_MUTE, 0, 1, 1, 0); | 223 | V4L2_CID_AUDIO_MUTE, 0, 1, 1, 0); |
249 | state->vol = v4l2_ctrl_new_std(&state->hdl, &wm8775_ctrl_ops, | ||
250 | V4L2_CID_AUDIO_VOLUME, 0, 65535, (65535+99)/100, 0xCF00); /* 0dB*/ | ||
251 | state->bal = v4l2_ctrl_new_std(&state->hdl, &wm8775_ctrl_ops, | ||
252 | V4L2_CID_AUDIO_BALANCE, 0, 65535, (65535+99)/100, 32768); | ||
253 | state->loud = v4l2_ctrl_new_std(&state->hdl, &wm8775_ctrl_ops, | ||
254 | V4L2_CID_AUDIO_LOUDNESS, 0, 1, 1, 1); | ||
255 | sd->ctrl_handler = &state->hdl; | 224 | sd->ctrl_handler = &state->hdl; |
256 | err = state->hdl.error; | 225 | if (state->hdl.error) { |
257 | if (err) { | 226 | int err = state->hdl.error; |
227 | |||
258 | v4l2_ctrl_handler_free(&state->hdl); | 228 | v4l2_ctrl_handler_free(&state->hdl); |
259 | kfree(state); | 229 | kfree(state); |
260 | return err; | 230 | return err; |
@@ -266,25 +236,29 @@ static int wm8775_probe(struct i2c_client *client, | |||
266 | wm8775_write(sd, R23, 0x000); | 236 | wm8775_write(sd, R23, 0x000); |
267 | /* Disable zero cross detect timeout */ | 237 | /* Disable zero cross detect timeout */ |
268 | wm8775_write(sd, R7, 0x000); | 238 | wm8775_write(sd, R7, 0x000); |
269 | /* HPF enable, I2S mode, 24-bit */ | 239 | /* Left justified, 24-bit mode */ |
270 | wm8775_write(sd, R11, 0x022); | 240 | wm8775_write(sd, R11, 0x021); |
271 | /* Master mode, clock ratio 256fs */ | 241 | /* Master mode, clock ratio 256fs */ |
272 | wm8775_write(sd, R12, 0x102); | 242 | wm8775_write(sd, R12, 0x102); |
273 | /* Powered up */ | 243 | /* Powered up */ |
274 | wm8775_write(sd, R13, 0x000); | 244 | wm8775_write(sd, R13, 0x000); |
275 | /* ALC stereo, ALC target level -5dB FS, ALC max gain +8dB */ | 245 | /* ADC gain +2.5dB, enable zero cross */ |
276 | wm8775_write(sd, R16, 0x1bb); | 246 | wm8775_write(sd, R14, 0x1d4); |
277 | /* Set ALC mode and hold time */ | 247 | /* ADC gain +2.5dB, enable zero cross */ |
278 | wm8775_write(sd, R17, (state->loud->val ? ALC_EN : 0) | ALC_HOLD); | 248 | wm8775_write(sd, R15, 0x1d4); |
249 | /* ALC Stereo, ALC target level -1dB FS max gain +8dB */ | ||
250 | wm8775_write(sd, R16, 0x1bf); | ||
251 | /* Enable gain control, use zero cross detection, | ||
252 | ALC hold time 42.6 ms */ | ||
253 | wm8775_write(sd, R17, 0x185); | ||
279 | /* ALC gain ramp up delay 34 s, ALC gain ramp down delay 33 ms */ | 254 | /* ALC gain ramp up delay 34 s, ALC gain ramp down delay 33 ms */ |
280 | wm8775_write(sd, R18, 0x0a2); | 255 | wm8775_write(sd, R18, 0x0a2); |
281 | /* Enable noise gate, threshold -72dBfs */ | 256 | /* Enable noise gate, threshold -72dBfs */ |
282 | wm8775_write(sd, R19, 0x005); | 257 | wm8775_write(sd, R19, 0x005); |
283 | /* Transient window 4ms, ALC min gain -5dB */ | 258 | /* Transient window 4ms, lower PGA gain limit -1dB */ |
284 | wm8775_write(sd, R20, 0x0fb); | 259 | wm8775_write(sd, R20, 0x07a); |
285 | 260 | /* LRBOTH = 1, use input 2. */ | |
286 | wm8775_set_audio(sd, 1); /* set volume/mute/mux */ | 261 | wm8775_write(sd, R21, 0x102); |
287 | |||
288 | return 0; | 262 | return 0; |
289 | } | 263 | } |
290 | 264 | ||