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

Commit 0d5a19f1 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (11297): cx23885: convert to v4l2_subdev.



Convert this driver to v4l2_subdev. Note that currently the only card with
analog support in this driver is the HVR-1800. The analog tuner support in
this driver is limited to what is needed for this board. When analog support
is added for other cards, then the tuner load code will probably have to be
expanded to take care of those boards. For example, there is currently no
support for either radio tuners or tda9887 demods.

I'd like to thank Steven Toth for testing this on his HVR-1800.

Tested-by: default avatarSteven Toth <stoth@linuxtv.org>
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent d35ed627
Loading
Loading
Loading
Loading
+6 −14
Original line number Diff line number Diff line
@@ -1251,8 +1251,7 @@ static int vidioc_g_tuner(struct file *file, void *priv,
	if (0 != t->index)
		return -EINVAL;
	strcpy(t->name, "Television");
	cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_G_TUNER, t);
	cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_G_TUNER, t);
	call_all(dev, tuner, g_tuner, t);

	dprintk(1, "VIDIOC_G_TUNER: tuner type %d\n", t->type);

@@ -1269,7 +1268,7 @@ static int vidioc_s_tuner(struct file *file, void *priv,
		return -EINVAL;

	/* Update the A/V core */
	cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_TUNER, t);
	call_all(dev, tuner, s_tuner, t);

	return 0;
}
@@ -1285,8 +1284,7 @@ static int vidioc_g_frequency(struct file *file, void *priv,
	f->type = V4L2_TUNER_ANALOG_TV;
	f->frequency = dev->freq;

	/* Assumption that tuner is always on bus 1 */
	cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_G_FREQUENCY, f);
	call_all(dev, tuner, g_frequency, f);

	return 0;
}
@@ -1313,8 +1311,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
		return -EINVAL;
	dev->freq = f->frequency;

	/* Assumption that tuner is always on bus 1 */
	cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY, f);
	call_all(dev, tuner, s_frequency, f);

	cx23885_initialize_codec(dev);

@@ -1328,7 +1325,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
	struct cx23885_dev *dev = fh->dev;

	/* Update the A/V core */
	cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_CTRL, ctl);
	call_all(dev, core, s_ctrl, ctl);
	return 0;
}

@@ -1524,12 +1521,7 @@ static int vidioc_log_status(struct file *file, void *priv)
	printk(KERN_INFO
		"%s/2: ============  START LOG STATUS  ============\n",
	       dev->name);
	cx23885_call_i2c_clients(&dev->i2c_bus[0], VIDIOC_LOG_STATUS,
		NULL);
	cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_LOG_STATUS,
		NULL);
	cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_LOG_STATUS,
		NULL);
	call_all(dev, core, log_status);
	cx2341x_log_status(&dev->mpeg_params, name);
	printk(KERN_INFO
		"%s/2: =============  END LOG STATUS  =============\n",
+3 −1
Original line number Diff line number Diff line
@@ -739,7 +739,9 @@ void cx23885_card_setup(struct cx23885_dev *dev)
	case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
	case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
	case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
		request_module("cx25840");
		dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->i2c_bus[2].i2c_adap,
				"cx25840", "cx25840", 0x88 >> 1);
		v4l2_subdev_call(dev->sd_cx25840, core, init, 0);
		break;
	}

+1 −1
Original line number Diff line number Diff line
@@ -875,7 +875,7 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
	cx23885_i2c_register(&dev->i2c_bus[1]);
	cx23885_i2c_register(&dev->i2c_bus[2]);
	cx23885_card_setup(dev);
	cx23885_call_i2c_clients(&dev->i2c_bus[0], TUNER_SET_STANDBY, NULL);
	call_all(dev, core, s_standby, 0);
	cx23885_ir_init(dev);

	if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) {
+1 −1
Original line number Diff line number Diff line
@@ -673,7 +673,7 @@ static int dvb_register(struct cx23885_tsport *port)
	fe0->dvb.frontend->callback = cx23885_tuner_callback;

	/* Put the analog decoder in standby to keep it quiet */
	cx23885_call_i2c_clients(i2c_bus, TUNER_SET_STANDBY, NULL);
	call_all(dev, core, s_standby, 0);

	if (fe0->dvb.frontend->ops.analog_ops.standby)
		fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
+4 −63
Original line number Diff line number Diff line
@@ -268,65 +268,6 @@ static int i2c_xfer(struct i2c_adapter *i2c_adap,
	return retval;
}

static int attach_inform(struct i2c_client *client)
{
	struct v4l2_device *v4l2_dev = i2c_get_adapdata(client->adapter);
	struct cx23885_dev *dev = to_cx23885(v4l2_dev);
	struct tuner_setup tun_setup;

	dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n",
		client->driver->driver.name, client->addr, client->name);

	if (!client->driver->command)
		return 0;

	if (dev->tuner_type != UNSET) {

		dprintk(1, "%s  (tuner) i2c attach [addr=0x%x,client=%s]\n",
			client->driver->driver.name, client->addr,
			client->name);

		if ((dev->tuner_addr == ADDR_UNSET) ||
			(dev->tuner_addr == client->addr)) {

			dprintk(1, "%s (tuner || addr UNSET)\n",
				client->driver->driver.name);

			dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n",
				client->driver->driver.name,
				client->addr, client->name);

			tun_setup.mode_mask = T_ANALOG_TV;
			tun_setup.type = dev->tuner_type;
			tun_setup.addr = dev->tuner_addr;

			client->driver->command(client, TUNER_SET_TYPE_ADDR,
				&tun_setup);
		}
	}

	return 0;
}

static int detach_inform(struct i2c_client *client)
{
	struct v4l2_device *v4l2_dev = i2c_get_adapdata(client->adapter);
	struct cx23885_dev *dev = to_cx23885(v4l2_dev);

	dprintk(1, "i2c detach [client=%s]\n", client->name);

	return 0;
}

void cx23885_call_i2c_clients(struct cx23885_i2c *bus,
			      unsigned int cmd, void *arg)
{
	if (bus->i2c_rc != 0)
		return;

	i2c_clients_command(&bus->i2c_adap, cmd, arg);
}

static u32 cx23885_functionality(struct i2c_adapter *adap)
{
	return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C;
@@ -344,9 +285,6 @@ static struct i2c_adapter cx23885_i2c_adap_template = {
	.owner             = THIS_MODULE,
	.id                = I2C_HW_B_CX23885,
	.algo              = &cx23885_i2c_algo_template,
	.class             = I2C_CLASS_TV_ANALOG,
	.client_register   = attach_inform,
	.client_unregister = detach_inform,
};

static struct i2c_client cx23885_i2c_client_template = {
@@ -410,8 +348,11 @@ int cx23885_i2c_register(struct cx23885_i2c *bus)

	if (0 == bus->i2c_rc) {
		dprintk(1, "%s: i2c bus %d registered\n", dev->name, bus->nr);
		if (i2c_scan)
		if (i2c_scan) {
			printk(KERN_INFO "%s: scan bus %d:\n",
					dev->name, bus->nr);
			do_i2c_scan(dev->name, &bus->i2c_client);
		}
	} else
		printk(KERN_WARNING "%s: i2c bus %d register FAILED\n",
			dev->name, bus->nr);
Loading