Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c37a4b5 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6:
  [media] em28xx: radio_fops should also use unlocked_ioctl
  [media] wm8775: Revert changeset fcb97573 to avoid a regression
  [media] cx25840: Prevent device probe failure due to volume control ERANGE error
parents d45fa563 8fd0bda5
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -1989,8 +1989,23 @@ static int cx25840_probe(struct i2c_client *client,
	v4l2_ctrl_new_std(&state->hdl, &cx25840_ctrl_ops,
			V4L2_CID_HUE, -128, 127, 1, 0);
	if (!is_cx2583x(state)) {
		default_volume = 228 - cx25840_read(client, 0x8d4);
		default_volume = ((default_volume / 2) + 23) << 9;
		default_volume = cx25840_read(client, 0x8d4);
		/*
		 * Enforce the legacy PVR-350/MSP3400 to PVR-150/CX25843 volume
		 * scale mapping limits to avoid -ERANGE errors when
		 * initializing the volume control
		 */
		if (default_volume > 228) {
			/* Bottom out at -96 dB, v4l2 vol range 0x2e00-0x2fff */
			default_volume = 228;
			cx25840_write(client, 0x8d4, 228);
		}
		else if (default_volume < 20) {
			/* Top out at + 8 dB, v4l2 vol range 0xfe00-0xffff */
			default_volume = 20;
			cx25840_write(client, 0x8d4, 20);
		}
		default_volume = (((228 - default_volume) >> 1) + 23) << 9;

		state->volume = v4l2_ctrl_new_std(&state->hdl,
			&cx25840_audio_ctrl_ops, V4L2_CID_AUDIO_VOLUME,
+12 −87
Original line number Diff line number Diff line
@@ -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,27 +586,6 @@ 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;
@@ -622,10 +600,10 @@ static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol,
	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);
	    cx_write(AUD_VOL_CTL, (old & ~0x3f) | v);
	    changed = 1;
	}
	if ((cx_read(AUD_BAL_CTL) & 0x7f) != b) {
	if (cx_read(AUD_BAL_CTL) != b) {
	    cx_write(AUD_BAL_CTL, b);
	    changed = 1;
	}
@@ -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",
+7 −0
Original line number Diff line number Diff line
@@ -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,
	},
+1 −26
Original line number Diff line number Diff line
@@ -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@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;
+2 −4
Original line number Diff line number Diff line
@@ -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;

Loading