[kernel/f14/master] Fix some v4l/dvb rebase buglets

Jarod Wilson jwilson at fedoraproject.org
Thu Jan 6 04:23:19 UTC 2011


commit 3ebdcc0e614905e93b5b4193e98a16c98f01ebb2
Author: Jarod Wilson <jarod at redhat.com>
Date:   Wed Jan 5 23:22:22 2011 -0500

    Fix some v4l/dvb rebase buglets
    
    - Restore functional audio on PVR-150 video capture cards (#666456)
    - Fix another mceusb regression cropping up mostly with rc5 signals (#662071)
    - Add back some ir-lirc-codec debug spew
    
    Signed-off-by: Jarod Wilson <jarod at redhat.com>

 kernel.spec                    |    7 +-
 linux-2.6-v4l-dvb-fixes.patch  |  556 ++++++++++++++++++++++++++++++++++++++++
 linux-2.6-v4l-dvb-update.patch |   24 +-
 3 files changed, 575 insertions(+), 12 deletions(-)
---
diff --git a/kernel.spec b/kernel.spec
index aa3af05..e5f9fd9 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -48,7 +48,7 @@ Summary: The Linux kernel
 # reset this by hand to 1 (or to 0 and then use rpmdev-bumpspec).
 # scripts/rebase.sh should be made to do that for you, actually.
 #
-%global baserelease 75
+%global baserelease 76
 %global fedora_build %{baserelease}
 
 # base_sublevel is the kernel version we're starting with and patching
@@ -2082,6 +2082,11 @@ fi
 # and build.
 
 %changelog
+* Wed Jan 05 2011 Jarod Wilson <jarod at redhat.com> 2.6.35.10-76
+- Restore functional audio on PVR-150 video capture cards (#666456)
+- Fix another mceusb regression cropping up mostly with rc5 signals (#662071)
+- Add back some ir-lirc-codec debug spew
+
 * Thu Dec 30 2010 Jarod Wilson <jarod at redhat.com> 2.6.35.10-75
 - Fix imon 0xffdc device detection and oops on probe
 
diff --git a/linux-2.6-v4l-dvb-fixes.patch b/linux-2.6-v4l-dvb-fixes.patch
index ba623a3..7d58ab3 100644
--- a/linux-2.6-v4l-dvb-fixes.patch
+++ b/linux-2.6-v4l-dvb-fixes.patch
@@ -44,6 +44,24 @@ Date:   Wed Dec 15 18:45:42 2010 -0300
     Tested-by: Torsten Kaiser <just.for.lkml at googlemail.com>
     Signed-off-by: Mauro Carvalho Chehab <mchehab at redhat.com>
 
+commit 46e67acd5d4cacda758e871eebd15cef4e2c2665
+Author: Mauro Carvalho Chehab <mchehab at redhat.com>
+Date:   Mon 3 Jan 11:09:56 2011 -0200
+
+    [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 at md.metrocast.net>
+    Reported-by: Eric Sharkey <eric at lisaneric.org>
+    Reported-by: Auric <auric at aanet.com.au>
+    Reported by: David Gesswein <djg at pdp8online.com>
+    Signed-off-by: Mauro Carvalho Chehab <mchehab at redhat.com>
+
+
 Not yet upstream:
 commit b8f82c5b7258f0d82102347c52c8f4144ec03990
 Author: Kyle McMartin <kylem at redhat.com>
@@ -82,6 +100,18 @@ Date:   Mon Dec 27 23:04:02 2010 -0500
     
     Signed-off-by: Jarod Wilson <jarod at redhat.com>
 
+commit 183cb1bc602b95cb4b65004608ad637a8f07d724
+Author: Jarod Wilson <jarod at redhat.com>
+Date:   Wed Jan 5 10:16:13 2011 -0500
+
+    rc/ir-lirc-codec: add back debug spew
+    
+    Some occasionally useful debug spew disappeared as part of a feature
+    update a while back, and I'm finding myself in need of it again to help
+    diagnose some issues.
+    
+    Signed-off-by: Jarod Wilson <jarod at redhat.com>
+
 
 
 Index: linux-2.6.35.x86_64/drivers/media/video/bt8xx/bttv-driver.c
@@ -816,3 +846,529 @@ Index: linux-2.6.35.x86_64/drivers/media/rc/imon.c
  find_endpoint_failed:
  	mutex_unlock(&ictx->lock);
  	usb_free_urb(tx_urb);
+diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
+index f011c5d..31a98e2 100644
+--- a/drivers/media/rc/ir-lirc-codec.c
++++ b/drivers/media/rc/ir-lirc-codec.c
+@@ -1,4 +1,4 @@
+-/* ir-lirc-codec.c - ir-core to classic lirc interface bridge
++/* ir-lirc-codec.c - rc-core to classic lirc interface bridge
+  *
+  * Copyright (C) 2010 by Jarod Wilson <jarod at redhat.com>
+  *
+@@ -47,6 +47,7 @@ static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev)
+ 	/* Carrier reports */
+ 	if (ev.carrier_report) {
+ 		sample = LIRC_FREQUENCY(ev.carrier);
++		IR_dprintk(2, "carrier report (freq: %d)\n", sample);
+ 
+ 	/* Packet end */
+ 	} else if (ev.timeout) {
+@@ -62,6 +63,7 @@ static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev)
+ 			return 0;
+ 
+ 		sample = LIRC_TIMEOUT(ev.duration / 1000);
++		IR_dprintk(2, "timeout report (duration: %d)\n", sample);
+ 
+ 	/* Normal sample */
+ 	} else {
+@@ -85,6 +87,8 @@ static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev)
+ 
+ 		sample = ev.pulse ? LIRC_PULSE(ev.duration / 1000) :
+ 					LIRC_SPACE(ev.duration / 1000);
++		IR_dprintk(2, "delivering %uus %s to lirc_dev\n",
++			   TO_US(ev.duration), TO_STR(ev.pulse));
+ 	}
+ 
+ 	lirc_buffer_write(dev->raw->lirc.drv->rbuf,
+diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c
+index 4aaa47c..54b7fcd 100644
+--- a/drivers/media/video/cx88/cx88-alsa.c
++++ b/drivers/media/video/cx88/cx88-alsa.c
+@@ -40,7 +40,6 @@
+ #include <sound/control.h>
+ #include <sound/initval.h>
+ #include <sound/tlv.h>
+-#include <media/wm8775.h>
+ 
+ #include "cx88.h"
+ #include "cx88-reg.h"
+@@ -587,47 +586,26 @@ static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol,
+ 	int left, right, v, b;
+ 	int changed = 0;
+ 	u32 old;
+-	struct v4l2_control client_ctl;
+-
+-	/* Pass volume & balance onto any WM8775 */
+-	if (value->value.integer.value[0] >= value->value.integer.value[1]) {
+-		v = value->value.integer.value[0] << 10;
+-		b = value->value.integer.value[0] ?
+-			(0x8000 * value->value.integer.value[1]) / value->value.integer.value[0] :
+-			0x8000;
+-	} else {
+-		v = value->value.integer.value[1] << 10;
+-		b = value->value.integer.value[1] ?
+-		0xffff - (0x8000 * value->value.integer.value[0]) / value->value.integer.value[1] :
+-		0x8000;
+-	}
+-	client_ctl.value = v;
+-	client_ctl.id = V4L2_CID_AUDIO_VOLUME;
+-	call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl);
+-
+-	client_ctl.value = b;
+-	client_ctl.id = V4L2_CID_AUDIO_BALANCE;
+-	call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl);
+ 
+ 	left = value->value.integer.value[0] & 0x3f;
+ 	right = value->value.integer.value[1] & 0x3f;
+ 	b = right - left;
+ 	if (b < 0) {
+-		v = 0x3f - left;
+-		b = (-b) | 0x40;
++	    v = 0x3f - left;
++	    b = (-b) | 0x40;
+ 	} else {
+-		v = 0x3f - right;
++	    v = 0x3f - right;
+ 	}
+ 	/* Do we really know this will always be called with IRQs on? */
+ 	spin_lock_irq(&chip->reg_lock);
+ 	old = cx_read(AUD_VOL_CTL);
+ 	if (v != (old & 0x3f)) {
+-		cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, (old & ~0x3f) | v);
+-		changed = 1;
++	    cx_write(AUD_VOL_CTL, (old & ~0x3f) | v);
++	    changed = 1;
+ 	}
+-	if ((cx_read(AUD_BAL_CTL) & 0x7f) != b) {
+-		cx_write(AUD_BAL_CTL, b);
+-		changed = 1;
++	if (cx_read(AUD_BAL_CTL) != b) {
++	    cx_write(AUD_BAL_CTL, b);
++	    changed = 1;
+ 	}
+ 	spin_unlock_irq(&chip->reg_lock);
+ 
+@@ -640,7 +618,7 @@ static const struct snd_kcontrol_new snd_cx88_volume = {
+ 	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ 	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
+ 		  SNDRV_CTL_ELEM_ACCESS_TLV_READ,
+-	.name = "Analog-TV Volume",
++	.name = "Playback Volume",
+ 	.info = snd_cx88_volume_info,
+ 	.get = snd_cx88_volume_get,
+ 	.put = snd_cx88_volume_put,
+@@ -671,14 +649,7 @@ static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol,
+ 	vol = cx_read(AUD_VOL_CTL);
+ 	if (value->value.integer.value[0] != !(vol & bit)) {
+ 		vol ^= bit;
+-		cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, vol);
+-		/* Pass mute onto any WM8775 */
+-		if ((1<<6) == bit) {
+-			struct v4l2_control client_ctl;
+-			client_ctl.value = 0 != (vol & bit);
+-			client_ctl.id = V4L2_CID_AUDIO_MUTE;
+-			call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl);
+-		}
++		cx_write(AUD_VOL_CTL, vol);
+ 		ret = 1;
+ 	}
+ 	spin_unlock_irq(&chip->reg_lock);
+@@ -687,7 +658,7 @@ static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol,
+ 
+ static const struct snd_kcontrol_new snd_cx88_dac_switch = {
+ 	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+-	.name = "Audio-Out Switch",
++	.name = "Playback Switch",
+ 	.info = snd_ctl_boolean_mono_info,
+ 	.get = snd_cx88_switch_get,
+ 	.put = snd_cx88_switch_put,
+@@ -696,49 +667,13 @@ static const struct snd_kcontrol_new snd_cx88_dac_switch = {
+ 
+ static const struct snd_kcontrol_new snd_cx88_source_switch = {
+ 	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+-	.name = "Analog-TV Switch",
++	.name = "Capture Switch",
+ 	.info = snd_ctl_boolean_mono_info,
+ 	.get = snd_cx88_switch_get,
+ 	.put = snd_cx88_switch_put,
+ 	.private_value = (1<<6),
+ };
+ 
+-static int snd_cx88_alc_get(struct snd_kcontrol *kcontrol,
+-			       struct snd_ctl_elem_value *value)
+-{
+-	snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol);
+-	struct cx88_core *core = chip->core;
+-	struct v4l2_control client_ctl;
+-
+-	client_ctl.id = V4L2_CID_AUDIO_LOUDNESS;
+-	call_hw(core, WM8775_GID, core, g_ctrl, &client_ctl);
+-	value->value.integer.value[0] = client_ctl.value ? 1 : 0;
+-
+-	return 0;
+-}
+-
+-static int snd_cx88_alc_put(struct snd_kcontrol *kcontrol,
+-				       struct snd_ctl_elem_value *value)
+-{
+-	snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol);
+-	struct cx88_core *core = chip->core;
+-	struct v4l2_control client_ctl;
+-
+-	client_ctl.value = 0 != value->value.integer.value[0];
+-	client_ctl.id = V4L2_CID_AUDIO_LOUDNESS;
+-	call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl);
+-
+-	return 0;
+-}
+-
+-static struct snd_kcontrol_new snd_cx88_alc_switch = {
+-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+-	.name = "Line-In ALC Switch",
+-	.info = snd_ctl_boolean_mono_info,
+-	.get = snd_cx88_alc_get,
+-	.put = snd_cx88_alc_put,
+-};
+-
+ /****************************************************************************
+ 			Basic Flow for Sound Devices
+  ****************************************************************************/
+@@ -860,7 +795,6 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci,
+ {
+ 	struct snd_card  *card;
+ 	snd_cx88_card_t  *chip;
+-	struct v4l2_subdev *sd;
+ 	int              err;
+ 
+ 	if (devno >= SNDRV_CARDS)
+@@ -896,15 +830,6 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci,
+ 	if (err < 0)
+ 		goto error;
+ 
+-	/* If there's a wm8775 then add a Line-In ALC switch */
+-	list_for_each_entry(sd, &chip->core->v4l2_dev.subdevs, list) {
+-		if (WM8775_GID == sd->grp_id) {
+-			snd_ctl_add(card, snd_ctl_new1(&snd_cx88_alc_switch,
+-						       chip));
+-			break;
+-		}
+-	}
+-
+ 	strcpy (card->driver, "CX88x");
+ 	sprintf(card->shortname, "Conexant CX%x", pci->device);
+ 	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 9b9e169..0ccc2af 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[] = {
+ 		.radio_type	= UNSET,
+ 		.tuner_addr	= ADDR_UNSET,
+ 		.radio_addr	= ADDR_UNSET,
++		.audio_chip = V4L2_IDENT_WM8775,
+ 		.input		= {{
+ 			.type	= CX88_VMUX_DVB,
+ 			.vmux	= 0,
++			/* 2: Line-In */
++			.audioroute = 2,
+ 		},{
+ 			.type	= CX88_VMUX_COMPOSITE1,
+ 			.vmux	= 1,
++			/* 2: Line-In */
++			.audioroute = 2,
+ 		},{
+ 			.type	= CX88_VMUX_SVIDEO,
+ 			.vmux	= 2,
++			/* 2: Line-In */
++			.audioroute = 2,
+ 		}},
+ 		.mpeg           = CX88_MPEG_DVB,
+ 	},
+diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
+index 62cea95..d9249e5 100644
+--- a/drivers/media/video/cx88/cx88-video.c
++++ b/drivers/media/video/cx88/cx88-video.c
+@@ -40,7 +40,6 @@
+ #include "cx88.h"
+ #include <media/v4l2-common.h>
+ #include <media/v4l2-ioctl.h>
+-#include <media/wm8775.h>
+ 
+ MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards");
+ MODULE_AUTHOR("Gerd Knorr <kraxel at bytesex.org> [SuSE Labs]");
+@@ -977,7 +976,6 @@ int cx88_set_control(struct cx88_core *core, struct v4l2_control *ctl)
+ 	const struct cx88_ctrl *c = NULL;
+ 	u32 value,mask;
+ 	int i;
+-	struct v4l2_control client_ctl;
+ 
+ 	for (i = 0; i < CX8800_CTLS; i++) {
+ 		if (cx8800_ctls[i].v.id == ctl->id) {
+@@ -991,27 +989,6 @@ int cx88_set_control(struct cx88_core *core, struct v4l2_control *ctl)
+ 		ctl->value = c->v.minimum;
+ 	if (ctl->value > c->v.maximum)
+ 		ctl->value = c->v.maximum;
+-
+-	/* Pass changes onto any WM8775 */
+-	client_ctl.id = ctl->id;
+-	switch (ctl->id) {
+-	case V4L2_CID_AUDIO_MUTE:
+-		client_ctl.value = ctl->value;
+-		break;
+-	case V4L2_CID_AUDIO_VOLUME:
+-		client_ctl.value = (ctl->value) ?
+-			(0x90 + ctl->value) << 8 : 0;
+-		break;
+-	case V4L2_CID_AUDIO_BALANCE:
+-		client_ctl.value = ctl->value << 9;
+-		break;
+-	default:
+-		client_ctl.id = 0;
+-		break;
+-	}
+-	if (client_ctl.id)
+-		call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl);
+-
+ 	mask=c->mask;
+ 	switch (ctl->id) {
+ 	case V4L2_CID_AUDIO_BALANCE:
+@@ -1558,9 +1535,7 @@ static int radio_queryctrl (struct file *file, void *priv,
+ 	if (c->id <  V4L2_CID_BASE ||
+ 		c->id >= V4L2_CID_LASTP1)
+ 		return -EINVAL;
+-	if (c->id == V4L2_CID_AUDIO_MUTE ||
+-		c->id == V4L2_CID_AUDIO_VOLUME ||
+-		c->id == V4L2_CID_AUDIO_BALANCE) {
++	if (c->id == V4L2_CID_AUDIO_MUTE) {
+ 		for (i = 0; i < CX8800_CTLS; i++) {
+ 			if (cx8800_ctls[i].v.id == c->id)
+ 				break;
+diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
+index e8c732e..c9981e7 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)
+ 	return container_of(v4l2_dev, struct cx88_core, v4l2_dev);
+ }
+ 
+-#define call_hw(core, grpid, o, f, args...) \
++#define call_all(core, o, f, args...) 				\
+ 	do {							\
+ 		if (!core->i2c_rc) {				\
+ 			if (core->gate_ctrl)			\
+ 				core->gate_ctrl(core, 1);	\
+-			v4l2_device_call_all(&core->v4l2_dev, grpid, o, f, ##args); \
++			v4l2_device_call_all(&core->v4l2_dev, 0, o, f, ##args); \
+ 			if (core->gate_ctrl)			\
+ 				core->gate_ctrl(core, 0);	\
+ 		}						\
+ 	} while (0)
+ 
+-#define call_all(core, o, f, args...) call_hw(core, 0, o, f, ##args)
+-
+ struct cx8800_dev;
+ struct cx8802_dev;
+ 
+diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c
+index 1355256..fe8ef64 100644
+--- a/drivers/media/video/wm8775.c
++++ b/drivers/media/video/wm8775.c
+@@ -35,7 +35,6 @@
+ #include <media/v4l2-device.h>
+ #include <media/v4l2-chip-ident.h>
+ #include <media/v4l2-ctrls.h>
+-#include <media/wm8775.h>
+ 
+ MODULE_DESCRIPTION("wm8775 driver");
+ MODULE_AUTHOR("Ulf Eklund, Hans Verkuil");
+@@ -51,16 +50,10 @@ enum {
+ 	TOT_REGS
+ };
+ 
+-#define ALC_HOLD 0x85 /* R17: use zero cross detection, ALC hold time 42.6 ms */
+-#define ALC_EN 0x100  /* R17: ALC enable */
+-
+ struct wm8775_state {
+ 	struct v4l2_subdev sd;
+ 	struct v4l2_ctrl_handler hdl;
+ 	struct v4l2_ctrl *mute;
+-	struct v4l2_ctrl *vol;
+-	struct v4l2_ctrl *bal;
+-	struct v4l2_ctrl *loud;
+ 	u8 input;		/* Last selected input (0-0xf) */
+ };
+ 
+@@ -92,30 +85,6 @@ static int wm8775_write(struct v4l2_subdev *sd, int reg, u16 val)
+ 	return -1;
+ }
+ 
+-static void wm8775_set_audio(struct v4l2_subdev *sd, int quietly)
+-{
+-	struct wm8775_state *state = to_state(sd);
+-	u8 vol_l, vol_r;
+-	int muted = 0 != state->mute->val;
+-	u16 volume = (u16)state->vol->val;
+-	u16 balance = (u16)state->bal->val;
+-
+-	/* normalize ( 65535 to 0 -> 255 to 0 (+24dB to -103dB) ) */
+-	vol_l = (min(65536 - balance, 32768) * volume) >> 23;
+-	vol_r = (min(balance, (u16)32768) * volume) >> 23;
+-
+-	/* Mute */
+-	if (muted || quietly)
+-		wm8775_write(sd, R21, 0x0c0 | state->input);
+-
+-	wm8775_write(sd, R14, vol_l | 0x100); /* 0x100= Left channel ADC zero cross enable */
+-	wm8775_write(sd, R15, vol_r | 0x100); /* 0x100= Right channel ADC zero cross enable */
+-
+-	/* Un-mute */
+-	if (!muted)
+-		wm8775_write(sd, R21, state->input);
+-}
+-
+ static int wm8775_s_routing(struct v4l2_subdev *sd,
+ 			    u32 input, u32 output, u32 config)
+ {
+@@ -133,26 +102,25 @@ static int wm8775_s_routing(struct v4l2_subdev *sd,
+ 	state->input = input;
+ 	if (!v4l2_ctrl_g_ctrl(state->mute))
+ 		return 0;
+-	if (!v4l2_ctrl_g_ctrl(state->vol))
+-		return 0;
+-	if (!v4l2_ctrl_g_ctrl(state->bal))
+-		return 0;
+-	wm8775_set_audio(sd, 1);
++	wm8775_write(sd, R21, 0x0c0);
++	wm8775_write(sd, R14, 0x1d4);
++	wm8775_write(sd, R15, 0x1d4);
++	wm8775_write(sd, R21, 0x100 + state->input);
+ 	return 0;
+ }
+ 
+ static int wm8775_s_ctrl(struct v4l2_ctrl *ctrl)
+ {
+ 	struct v4l2_subdev *sd = to_sd(ctrl);
++	struct wm8775_state *state = to_state(sd);
+ 
+ 	switch (ctrl->id) {
+ 	case V4L2_CID_AUDIO_MUTE:
+-	case V4L2_CID_AUDIO_VOLUME:
+-	case V4L2_CID_AUDIO_BALANCE:
+-		wm8775_set_audio(sd, 0);
+-		return 0;
+-	case V4L2_CID_AUDIO_LOUDNESS:
+-		wm8775_write(sd, R17, (ctrl->val ? ALC_EN : 0) | ALC_HOLD);
++		wm8775_write(sd, R21, 0x0c0);
++		wm8775_write(sd, R14, 0x1d4);
++		wm8775_write(sd, R15, 0x1d4);
++		if (!ctrl->val)
++			wm8775_write(sd, R21, 0x100 + state->input);
+ 		return 0;
+ 	}
+ 	return -EINVAL;
+@@ -176,7 +144,16 @@ static int wm8775_log_status(struct v4l2_subdev *sd)
+ 
+ static int wm8775_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *freq)
+ {
+-	wm8775_set_audio(sd, 0);
++	struct wm8775_state *state = to_state(sd);
++
++	/* If I remove this, then it can happen that I have no
++	   sound the first time I tune from static to a valid channel.
++	   It's difficult to reproduce and is almost certainly related
++	   to the zero cross detect circuit. */
++	wm8775_write(sd, R21, 0x0c0);
++	wm8775_write(sd, R14, 0x1d4);
++	wm8775_write(sd, R15, 0x1d4);
++	wm8775_write(sd, R21, 0x100 + state->input);
+ 	return 0;
+ }
+ 
+@@ -226,7 +203,6 @@ static int wm8775_probe(struct i2c_client *client,
+ {
+ 	struct wm8775_state *state;
+ 	struct v4l2_subdev *sd;
+-	int err;
+ 
+ 	/* Check if the adapter supports the needed features */
+ 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+@@ -240,21 +216,15 @@ static int wm8775_probe(struct i2c_client *client,
+ 		return -ENOMEM;
+ 	sd = &state->sd;
+ 	v4l2_i2c_subdev_init(sd, client, &wm8775_ops);
+-	sd->grp_id = WM8775_GID; /* subdev group id */
+ 	state->input = 2;
+ 
+-	v4l2_ctrl_handler_init(&state->hdl, 4);
++	v4l2_ctrl_handler_init(&state->hdl, 1);
+ 	state->mute = v4l2_ctrl_new_std(&state->hdl, &wm8775_ctrl_ops,
+ 			V4L2_CID_AUDIO_MUTE, 0, 1, 1, 0);
+-	state->vol = v4l2_ctrl_new_std(&state->hdl, &wm8775_ctrl_ops,
+-			V4L2_CID_AUDIO_VOLUME, 0, 65535, (65535+99)/100, 0xCF00); /* 0dB*/
+-	state->bal = v4l2_ctrl_new_std(&state->hdl, &wm8775_ctrl_ops,
+-			V4L2_CID_AUDIO_BALANCE, 0, 65535, (65535+99)/100, 32768);
+-	state->loud = v4l2_ctrl_new_std(&state->hdl, &wm8775_ctrl_ops,
+-			V4L2_CID_AUDIO_LOUDNESS, 0, 1, 1, 1);
+ 	sd->ctrl_handler = &state->hdl;
+-	err = state->hdl.error;
+-	if (err) {
++	if (state->hdl.error) {
++		int err = state->hdl.error;
++
+ 		v4l2_ctrl_handler_free(&state->hdl);
+ 		kfree(state);
+ 		return err;
+@@ -266,25 +236,29 @@ static int wm8775_probe(struct i2c_client *client,
+ 	wm8775_write(sd, R23, 0x000);
+ 	/* Disable zero cross detect timeout */
+ 	wm8775_write(sd, R7, 0x000);
+-	/* HPF enable, I2S mode, 24-bit */
+-	wm8775_write(sd, R11, 0x022);
++	/* Left justified, 24-bit mode */
++	wm8775_write(sd, R11, 0x021);
+ 	/* Master mode, clock ratio 256fs */
+ 	wm8775_write(sd, R12, 0x102);
+ 	/* Powered up */
+ 	wm8775_write(sd, R13, 0x000);
+-	/* ALC stereo, ALC target level -5dB FS, ALC max gain +8dB */
+-	wm8775_write(sd, R16, 0x1bb);
+-	/* Set ALC mode and hold time */
+-	wm8775_write(sd, R17, (state->loud->val ? ALC_EN : 0) | ALC_HOLD);
++	/* ADC gain +2.5dB, enable zero cross */
++	wm8775_write(sd, R14, 0x1d4);
++	/* ADC gain +2.5dB, enable zero cross */
++	wm8775_write(sd, R15, 0x1d4);
++	/* ALC Stereo, ALC target level -1dB FS max gain +8dB */
++	wm8775_write(sd, R16, 0x1bf);
++	/* Enable gain control, use zero cross detection,
++	   ALC hold time 42.6 ms */
++	wm8775_write(sd, R17, 0x185);
+ 	/* ALC gain ramp up delay 34 s, ALC gain ramp down delay 33 ms */
+ 	wm8775_write(sd, R18, 0x0a2);
+ 	/* Enable noise gate, threshold -72dBfs */
+ 	wm8775_write(sd, R19, 0x005);
+-	/* Transient window 4ms, ALC min gain -5dB  */
+-	wm8775_write(sd, R20, 0x0fb);
+-
+-	wm8775_set_audio(sd, 1);      /* set volume/mute/mux */
+-
++	/* Transient window 4ms, lower PGA gain limit -1dB */
++	wm8775_write(sd, R20, 0x07a);
++	/* LRBOTH = 1, use input 2. */
++	wm8775_write(sd, R21, 0x102);
+ 	return 0;
+ }
+ 
+diff --git a/include/media/wm8775.h b/include/media/wm8775.h
+index a1c4d41..60739c5 100644
+--- a/include/media/wm8775.h
++++ b/include/media/wm8775.h
+@@ -32,7 +32,4 @@
+ #define WM8775_AIN3 4
+ #define WM8775_AIN4 8
+ 
+-/* subdev group ID */
+-#define WM8775_GID (1 << 0)
+-
+ #endif
diff --git a/linux-2.6-v4l-dvb-update.patch b/linux-2.6-v4l-dvb-update.patch
index 21b5d3b..fe78965 100644
--- a/linux-2.6-v4l-dvb-update.patch
+++ b/linux-2.6-v4l-dvb-update.patch
@@ -28880,27 +28880,27 @@ Index: linux-2.6.35.x86_64/drivers/media/rc/ene_ir.c
 +
 +select_timeout:
 +	if (dev->rx_fan_input_inuse) {
-+		dev->rdev->rx_resolution = MS_TO_US(ENE_FW_SAMPLE_PERIOD_FAN);
++		dev->rdev->rx_resolution = US_TO_NS(ENE_FW_SAMPLE_PERIOD_FAN);
 +
 +		/* Fan input doesn't support timeouts, it just ends the
 +			input with a maximum sample */
 +		dev->rdev->min_timeout = dev->rdev->max_timeout =
-+			MS_TO_US(ENE_FW_SMPL_BUF_FAN_MSK *
++			US_TO_NS(ENE_FW_SMPL_BUF_FAN_MSK *
 +				ENE_FW_SAMPLE_PERIOD_FAN);
 +	} else {
-+		dev->rdev->rx_resolution = MS_TO_US(sample_period);
++		dev->rdev->rx_resolution = US_TO_NS(sample_period);
 +
 +		/* Theoreticly timeout is unlimited, but we cap it
 +		 * because it was seen that on one device, it
 +		 * would stop sending spaces after around 250 msec.
 +		 * Besides, this is close to 2^32 anyway and timeout is u32.
 +		 */
-+		dev->rdev->min_timeout = MS_TO_US(127 * sample_period);
-+		dev->rdev->max_timeout = MS_TO_US(200000);
++		dev->rdev->min_timeout = US_TO_NS(127 * sample_period);
++		dev->rdev->max_timeout = US_TO_NS(200000);
 +	}
 +
 +	if (dev->hw_learning_and_tx_capable)
-+		dev->rdev->tx_resolution = MS_TO_US(sample_period);
++		dev->rdev->tx_resolution = US_TO_NS(sample_period);
 +
 +	if (dev->rdev->timeout > dev->rdev->max_timeout)
 +		dev->rdev->timeout = dev->rdev->max_timeout;
@@ -29235,7 +29235,7 @@ Index: linux-2.6.35.x86_64/drivers/media/rc/ene_ir.c
 +
 +		dbg("RX: %d (%s)", hw_sample, pulse ? "pulse" : "space");
 +
-+		ev.duration = MS_TO_US(hw_sample);
++		ev.duration = US_TO_NS(hw_sample);
 +		ev.pulse = pulse;
 +		ir_raw_event_store_with_filter(dev->rdev, &ev);
 +	}
@@ -29255,7 +29255,7 @@ Index: linux-2.6.35.x86_64/drivers/media/rc/ene_ir.c
 +	dev->learning_mode_enabled = learning_mode_force;
 +
 +	/* Set reasonable default timeout */
-+	dev->rdev->timeout = MS_TO_US(150000);
++	dev->rdev->timeout = US_TO_NS(150000);
 +}
 +
 +/* Upload all hardware settings at once. Used at load and resume time */
@@ -44646,7 +44646,7 @@ Index: linux-2.6.35.x86_64/drivers/media/rc/mceusb.c
 +	switch (ir->buf_in[index]) {
 +	/* 2-byte return value commands */
 +	case MCE_CMD_S_TIMEOUT:
-+		ir->rc->timeout = MS_TO_US((hi << 8 | lo) / 2);
++		ir->rc->timeout = MS_TO_NS((hi << 8 | lo) / 2);
 +		break;
 +
 +	/* 1-byte return value commands */
@@ -44890,7 +44890,7 @@ Index: linux-2.6.35.x86_64/drivers/media/rc/mceusb.c
 +	rc->priv = ir;
 +	rc->driver_type = RC_DRIVER_IR_RAW;
 +	rc->allowed_protos = RC_TYPE_ALL;
-+	rc->timeout = MS_TO_US(1000);
++	rc->timeout = MS_TO_NS(1000);
 +	if (!ir->flags.no_tx) {
 +		rc->s_tx_mask = mceusb_set_tx_mask;
 +		rc->s_tx_carrier = mceusb_set_tx_carrier;
@@ -166126,7 +166126,7 @@ Index: linux-2.6.35.x86_64/include/media/rc-core.h
 ===================================================================
 --- /dev/null
 +++ linux-2.6.35.x86_64/include/media/rc-core.h
-@@ -0,0 +1,221 @@
+@@ -0,0 +1,223 @@
 +/*
 + * Remote Controller core header
 + *
@@ -166312,7 +166312,9 @@ Index: linux-2.6.35.x86_64/include/media/rc-core.h
 +}
 +
 +#define IR_MAX_DURATION         0xFFFFFFFF      /* a bit more than 4 seconds */
++#define US_TO_NS(usec)		((usec) * 1000)
 +#define MS_TO_US(msec)		((msec) * 1000)
++#define MS_TO_NS(msec)		((msec) * 1000 * 1000)
 +
 +void ir_raw_event_handle(struct rc_dev *dev);
 +int ir_raw_event_store(struct rc_dev *dev, struct ir_raw_event *ev);


More information about the scm-commits mailing list