History

[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.

Mauro Carvalho Chehab committed 15 years ago

Commit 46e67ac1 parent f23b7956 files · +61 −185Browse files

Unified · Split

6 files
  1. drivers/media/video/cx88/cx88-alsa.c +12 −87
  2. drivers/media/video/cx88/cx88-cards.c +7 −0
  3. drivers/media/video/cx88/cx88-video.c +1 −26
  4. drivers/media/video/cx88/cx88.h +2 −4
  5. drivers/media/video/wm8775.c +39 −65
  6. include/media/wm8775.h +0 −3
drivers/media/video/cx88/cx88-alsa.c+12−87
@@ -40,7 +40,6 @@ · 39 unmodified lines
4040 #include <sound/control.h>
4141 #include <sound/initval.h>
4242 #include <sound/tlv.h>
43−#include <media/wm8775.h>
4443
4544 #include "cx88.h"
4645 #include "cx88-reg.h"
@@ -587,47 +586,26 @@ static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol, · 540 unmodified lines
587586 int left, right, v, b;
588587 int changed = 0;
589588 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);
611589
612590 left = value->value.integer.value[0] & 0x3f;
613591 right = value->value.integer.value[1] & 0x3f;
614592 b = right - left;
615593 if (b < 0) {
616− v = 0x3f - left;
617− b = (-b) | 0x40;
594+ v = 0x3f - left;
595+ b = (-b) | 0x40;
618596 } else {
619− v = 0x3f - right;
597+ v = 0x3f - right;
620598 }
621599 /* Do we really know this will always be called with IRQs on? */
622600 spin_lock_irq(&chip->reg_lock);
623601 old = cx_read(AUD_VOL_CTL);
624602 if (v != (old & 0x3f)) {
625− cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, (old & ~0x3f) | v);
626− changed = 1;
603+ cx_write(AUD_VOL_CTL, (old & ~0x3f) | v);
604+ changed = 1;
627605 }
628− if ((cx_read(AUD_BAL_CTL) & 0x7f) != b) {
629− cx_write(AUD_BAL_CTL, b);
630− changed = 1;
606+ if (cx_read(AUD_BAL_CTL) != b) {
607+ cx_write(AUD_BAL_CTL, b);
608+ changed = 1;
631609 }
632610 spin_unlock_irq(&chip->reg_lock);
633611
@@ -640,7 +618,7 @@ static const struct snd_kcontrol_new snd_cx88_volume = { · 6 unmodified lines
640618 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
641619 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
642620 SNDRV_CTL_ELEM_ACCESS_TLV_READ,
643− .name = "Analog-TV Volume",
621+ .name = "Playback Volume",
644622 .info = snd_cx88_volume_info,
645623 .get = snd_cx88_volume_get,
646624 .put = snd_cx88_volume_put,
@@ -671,14 +649,7 @@ static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol, · 24 unmodified lines
671649 vol = cx_read(AUD_VOL_CTL);
672650 if (value->value.integer.value[0] != !(vol & bit)) {
673651 vol ^= bit;
674− cx_swrite(SHADOW_AUD_VOL_CTL, 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− }
652+ cx_write(AUD_VOL_CTL, vol);
682653 ret = 1;
683654 }
684655 spin_unlock_irq(&chip->reg_lock);
@@ -687,7 +658,7 @@ static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol, · 2 unmodified lines
687658
688659 static const struct snd_kcontrol_new snd_cx88_dac_switch = {
689660 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
690− .name = "Audio-Out Switch",
661+ .name = "Playback Switch",
691662 .info = snd_ctl_boolean_mono_info,
692663 .get = snd_cx88_switch_get,
693664 .put = snd_cx88_switch_put,
@@ -696,49 +667,13 @@ static const struct snd_kcontrol_new snd_cx88_dac_switch = { · 2 unmodified lines
696667
697668 static const struct snd_kcontrol_new snd_cx88_source_switch = {
698669 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
699− .name = "Analog-TV Switch",
670+ .name = "Capture Switch",
700671 .info = snd_ctl_boolean_mono_info,
701672 .get = snd_cx88_switch_get,
702673 .put = snd_cx88_switch_put,
703674 .private_value = (1<<6),
704675 };
705676
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−
742677 /****************************************************************************
743678 Basic Flow for Sound Devices
744679 ****************************************************************************/
@@ -860,7 +795,6 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci, · 115 unmodified lines
860795 {
861796 struct snd_card *card;
862797 snd_cx88_card_t *chip;
863− struct v4l2_subdev *sd;
864798 int err;
865799
866800 if (devno >= SNDRV_CARDS)
@@ -896,15 +830,6 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci, · 29 unmodified lines
896830 if (err < 0)
897831 goto error;
898832
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−
908833 strcpy (card->driver, "CX88x");
909834 sprintf(card->shortname, "Conexant CX%x", pci->device);
910835 sprintf(card->longname, "%s at %#llx",
drivers/media/video/cx88/cx88-cards.c+7−0
@@ -1007,15 +1007,22 @@ static const struct cx88_board cx88_boards[] = { · 1006 unmodified lines
10071007 .radio_type = UNSET,
10081008 .tuner_addr = ADDR_UNSET,
10091009 .radio_addr = ADDR_UNSET,
1010+ .audio_chip = V4L2_IDENT_WM8775,
10101011 .input = {{
10111012 .type = CX88_VMUX_DVB,
10121013 .vmux = 0,
1014+ /* 2: Line-In */
1015+ .audioroute = 2,
10131016 },{
10141017 .type = CX88_VMUX_COMPOSITE1,
10151018 .vmux = 1,
1019+ /* 2: Line-In */
1020+ .audioroute = 2,
10161021 },{
10171022 .type = CX88_VMUX_SVIDEO,
10181023 .vmux = 2,
1024+ /* 2: Line-In */
1025+ .audioroute = 2,
10191026 }},
10201027 .mpeg = CX88_MPEG_DVB,
10211028 },
drivers/media/video/cx88/cx88-video.c+1−26
@@ -40,7 +40,6 @@ · 39 unmodified lines
4040 #include "cx88.h"
4141 #include <media/v4l2-common.h>
4242 #include <media/v4l2-ioctl.h>
43−#include <media/wm8775.h>
4443
4544 MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards");
4645 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) · 930 unmodified lines
977976 const struct cx88_ctrl *c = NULL;
978977 u32 value,mask;
979978 int i;
980− struct v4l2_control client_ctl;
981979
982980 for (i = 0; i < CX8800_CTLS; i++) {
983981 if (cx8800_ctls[i].v.id == ctl->id) {
@@ -991,27 +989,6 @@ int cx88_set_control(struct cx88_core *core, struct v4l2_control *ctl) · 7 unmodified lines
991989 ctl->value = c->v.minimum;
992990 if (ctl->value > c->v.maximum)
993991 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−
1015992 mask=c->mask;
1016993 switch (ctl->id) {
1017994 case V4L2_CID_AUDIO_BALANCE:
@@ -1558,9 +1535,7 @@ static int radio_queryctrl (struct file *file, void *priv, · 540 unmodified lines
15581535 if (c->id < V4L2_CID_BASE ||
15591536 c->id >= V4L2_CID_LASTP1)
15601537 return -EINVAL;
1561− if (c->id == V4L2_CID_AUDIO_MUTE ||
1562− c->id == V4L2_CID_AUDIO_VOLUME ||
1563− c->id == V4L2_CID_AUDIO_BALANCE) {
1538+ if (c->id == V4L2_CID_AUDIO_MUTE) {
15641539 for (i = 0; i < CX8800_CTLS; i++) {
15651540 if (cx8800_ctls[i].v.id == c->id)
15661541 break;
drivers/media/video/cx88/cx88.h+2−4
@@ -398,19 +398,17 @@ static inline struct cx88_core *to_core(struct v4l2_device *v4l2_dev) · 397 unmodified lines
398398 return container_of(v4l2_dev, struct cx88_core, v4l2_dev);
399399 }
400400
401−#define call_hw(core, grpid, o, f, args...) \
401+#define call_all(core, o, f, args...) \
402402 do { \
403403 if (!core->i2c_rc) { \
404404 if (core->gate_ctrl) \
405405 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); \
407407 if (core->gate_ctrl) \
408408 core->gate_ctrl(core, 0); \
409409 } \
410410 } while (0)
411411
412−#define call_all(core, o, f, args...) call_hw(core, 0, o, f, ##args)
413−
414412 struct cx8800_dev;
415413 struct cx8802_dev;
416414
drivers/media/video/wm8775.c+39−65
@@ -35,7 +35,6 @@ · 34 unmodified lines
3535 #include <media/v4l2-device.h>
3636 #include <media/v4l2-chip-ident.h>
3737 #include <media/v4l2-ctrls.h>
38−#include <media/wm8775.h>
3938
4039 MODULE_DESCRIPTION("wm8775 driver");
4140 MODULE_AUTHOR("Ulf Eklund, Hans Verkuil");
@@ -51,16 +50,10 @@ enum { · 9 unmodified lines
5150 TOT_REGS
5251 };
5352
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−
5753 struct wm8775_state {
5854 struct v4l2_subdev sd;
5955 struct v4l2_ctrl_handler hdl;
6056 struct v4l2_ctrl *mute;
61− struct v4l2_ctrl *vol;
62− struct v4l2_ctrl *bal;
63− struct v4l2_ctrl *loud;
6457 u8 input; /* Last selected input (0-0xf) */
6558 };
6659
@@ -92,30 +85,6 @@ static int wm8775_write(struct v4l2_subdev *sd, int reg, u16 val) · 25 unmodified lines
9285 return -1;
9386 }
9487
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−
11988 static int wm8775_s_routing(struct v4l2_subdev *sd,
12089 u32 input, u32 output, u32 config)
12190 {
@@ -133,26 +102,25 @@ static int wm8775_s_routing(struct v4l2_subdev *sd, · 11 unmodified lines
133102 state->input = input;
134103 if (!v4l2_ctrl_g_ctrl(state->mute))
135104 return 0;
136− if (!v4l2_ctrl_g_ctrl(state->vol))
137− return 0;
138− if (!v4l2_ctrl_g_ctrl(state->bal))
139− return 0;
140− wm8775_set_audio(sd, 1);
105+ wm8775_write(sd, R21, 0x0c0);
106+ wm8775_write(sd, R14, 0x1d4);
107+ wm8775_write(sd, R15, 0x1d4);
108+ wm8775_write(sd, R21, 0x100 + state->input);
141109 return 0;
142110 }
143111
144112 static int wm8775_s_ctrl(struct v4l2_ctrl *ctrl)
145113 {
146114 struct v4l2_subdev *sd = to_sd(ctrl);
115+ struct wm8775_state *state = to_state(sd);
147116
148117 switch (ctrl->id) {
149118 case V4L2_CID_AUDIO_MUTE:
150− case V4L2_CID_AUDIO_VOLUME:
151− case V4L2_CID_AUDIO_BALANCE:
152− wm8775_set_audio(sd, 0);
153− return 0;
154− case V4L2_CID_AUDIO_LOUDNESS:
155− wm8775_write(sd, R17, (ctrl->val ? ALC_EN : 0) | ALC_HOLD);
119+ wm8775_write(sd, R21, 0x0c0);
120+ wm8775_write(sd, R14, 0x1d4);
121+ wm8775_write(sd, R15, 0x1d4);
122+ if (!ctrl->val)
123+ wm8775_write(sd, R21, 0x100 + state->input);
156124 return 0;
157125 }
158126 return -EINVAL;
@@ -176,7 +144,16 @@ static int wm8775_log_status(struct v4l2_subdev *sd) · 17 unmodified lines
176144
177145 static int wm8775_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *freq)
178146 {
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);
180157 return 0;
181158 }
182159
@@ -226,7 +203,6 @@ static int wm8775_probe(struct i2c_client *client, · 43 unmodified lines
226203 {
227204 struct wm8775_state *state;
228205 struct v4l2_subdev *sd;
229− int err;
230206
231207 /* Check if the adapter supports the needed features */
232208 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
@@ -240,21 +216,15 @@ static int wm8775_probe(struct i2c_client *client, · 7 unmodified lines
240216 return -ENOMEM;
241217 sd = &state->sd;
242218 v4l2_i2c_subdev_init(sd, client, &wm8775_ops);
243− sd->grp_id = WM8775_GID; /* subdev group id */
244219 state->input = 2;
245220
246− v4l2_ctrl_handler_init(&state->hdl, 4);
221+ v4l2_ctrl_handler_init(&state->hdl, 1);
247222 state->mute = v4l2_ctrl_new_std(&state->hdl, &wm8775_ctrl_ops,
248223 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);
255224 sd->ctrl_handler = &state->hdl;
256− err = state->hdl.error;
257− if (err) {
225+ if (state->hdl.error) {
226+ int err = state->hdl.error;
227+
258228 v4l2_ctrl_handler_free(&state->hdl);
259229 kfree(state);
260230 return err;
@@ -266,25 +236,29 @@ static int wm8775_probe(struct i2c_client *client, · 5 unmodified lines
266236 wm8775_write(sd, R23, 0x000);
267237 /* Disable zero cross detect timeout */
268238 wm8775_write(sd, R7, 0x000);
269− /* HPF enable, I2S mode, 24-bit */
270− wm8775_write(sd, R11, 0x022);
239+ /* Left justified, 24-bit mode */
240+ wm8775_write(sd, R11, 0x021);
271241 /* Master mode, clock ratio 256fs */
272242 wm8775_write(sd, R12, 0x102);
273243 /* Powered up */
274244 wm8775_write(sd, R13, 0x000);
275− /* ALC stereo, ALC target level -5dB FS, ALC max gain +8dB */
276− wm8775_write(sd, R16, 0x1bb);
277− /* Set ALC mode and hold time */
278− wm8775_write(sd, R17, (state->loud->val ? ALC_EN : 0) | ALC_HOLD);
245+ /* ADC gain +2.5dB, enable zero cross */
246+ wm8775_write(sd, R14, 0x1d4);
247+ /* ADC gain +2.5dB, enable zero cross */
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);
279254 /* ALC gain ramp up delay 34 s, ALC gain ramp down delay 33 ms */
280255 wm8775_write(sd, R18, 0x0a2);
281256 /* Enable noise gate, threshold -72dBfs */
282257 wm8775_write(sd, R19, 0x005);
283− /* Transient window 4ms, ALC min gain -5dB */
284− wm8775_write(sd, R20, 0x0fb);
285−
286− wm8775_set_audio(sd, 1); /* set volume/mute/mux */
287−
258+ /* Transient window 4ms, lower PGA gain limit -1dB */
259+ wm8775_write(sd, R20, 0x07a);
260+ /* LRBOTH = 1, use input 2. */
261+ wm8775_write(sd, R21, 0x102);
288262 return 0;
289263 }
290264
include/media/wm8775.h+0−3
@@ -32,7 +32,4 @@ · 31 unmodified lines
3232 #define WM8775_AIN3 4
3333 #define WM8775_AIN4 8
3434
35−/* subdev group ID */
36−#define WM8775_GID (1 << 0)
37−
3835 #endif