Skip to content

Commit

Permalink
V4L/DVB (11128): cx231xx: convert the calls to subdev format
Browse files Browse the repository at this point in the history
This patch converts cx231xx to the new v4l2 dev/subdev, doing:
 - Conversion of i2c calls to subdev calls;
 - all subdev calls to call_all();
 - Corrected the header file order in cx231xx.h;
 - Added tuner frequency setting.

Signed-off-by: Srinivasa Deevi <srinivasa.deevi@conexant.com>
Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Sri Deevi authored and Mauro Carvalho Chehab committed Apr 7, 2009
1 parent ed559ed commit b119612
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 103 deletions.
61 changes: 45 additions & 16 deletions drivers/media/video/cx231xx/cx231xx-cards.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ void cx231xx_pre_card_setup(struct cx231xx *dev)

}

#if 0

static void cx231xx_config_tuner(struct cx231xx *dev)
{
struct tuner_setup tun_setup;
Expand All @@ -258,8 +256,8 @@ static void cx231xx_config_tuner(struct cx231xx *dev)
tun_setup.addr = dev->tuner_addr;
tun_setup.tuner_callback = cx231xx_tuner_callback;

cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_TYPE_ADDR,
&tun_setup);
tuner_call(dev, tuner, s_type_addr, &tun_setup);

#if 0
if (tun_setup.type == TUNER_XC5000) {
static struct xc2028_ctrl ctrl = {
Expand All @@ -271,20 +269,17 @@ static void cx231xx_config_tuner(struct cx231xx *dev)
.tuner = dev->tuner_type,
.priv = &ctrl,
};
cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_CONFIG,
&cfg);
tuner_call(dev, tuner, s_config, &cfg);
}
#endif

/* configure tuner */
f.tuner = 0;
f.type = V4L2_TUNER_ANALOG_TV;
f.frequency = 9076; /* just a magic number */
dev->ctl_freq = f.frequency;
cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY, &f);
}
call_all(dev, tuner, s_frequency, &f);

#endif
}

/* ----------------------------------------------------------------------- */
void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir)
Expand All @@ -308,6 +303,7 @@ void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir)

void cx231xx_card_setup(struct cx231xx *dev)
{

cx231xx_set_model(dev);

dev->tuner_type = cx231xx_boards[dev->model].tuner_type;
Expand All @@ -332,16 +328,29 @@ void cx231xx_card_setup(struct cx231xx *dev)
/* request some modules */
if (dev->board.decoder == CX231XX_AVDECODER) {
cx231xx_info(": Requesting cx25840 module\n");
request_module("cx25840");
dev->sd_cx25840 =
v4l2_i2c_new_subdev(&dev->i2c_bus[0].i2c_adap,
"cx25840", "cx25840", 0x88 >> 1);
if (dev->sd_cx25840 == NULL)
cx231xx_info("cx25840 subdev registration failure\n");
cx25840_call(dev, core, init, 0);

}
#if 0

if (dev->board.tuner_type != TUNER_ABSENT) {
cx231xx_info(": Requesting Tuner module\n");
request_module("tuner");
dev->sd_tuner =
v4l2_i2c_new_subdev(&dev->i2c_bus[1].i2c_adap,
"tuner", "tuner", 0xc2 >> 1);
if (dev->sd_tuner == NULL)
cx231xx_info("tuner subdev registration failure\n");

cx231xx_config_tuner(dev);
}

cx231xx_config_tuner(dev);

#if 0
/* TBD IR will be added later */
cx231xx_ir_init(dev);
#endif
Expand Down Expand Up @@ -371,7 +380,7 @@ void cx231xx_config_i2c(struct cx231xx *dev)
route.input = INPUT(dev->video_input)->vmux;
route.output = 0;

cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_STREAMON, NULL);
call_all(dev, video, s_stream, 1);
}

/*
Expand Down Expand Up @@ -549,7 +558,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
udev = usb_get_dev(interface_to_usbdev(interface));
ifnum = interface->altsetting[0].desc.bInterfaceNumber;

cx231xx_info(": Interface Number %d\n", ifnum);
printk(DRIVER_NAME ": Interface Number %d\n", ifnum);

/* Interface number 0 - IR interface */
if (ifnum == 0) {
Expand Down Expand Up @@ -689,12 +698,25 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
/* AV device initialization */
if ((dev->interface_count - 1) == dev->max_iad_interface_count) {
cx231xx_info(" Calling init_dev\n");

/* Create v4l2 device */
snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name),
"%s-%03d", "cx231xx", nr);
retval = v4l2_device_register(&udev->dev, &dev->v4l2_dev);
if (retval) {
printk(KERN_ERR "%s() v4l2_device_register failed\n",
__func__);
cx231xx_devused &= ~(1 << nr);
kfree(dev);
return -EIO;
}

/* allocate device struct */
retval = cx231xx_init_dev(&dev, udev, nr);
if (retval) {
cx231xx_devused &= ~(1 << dev->devno);
v4l2_device_unregister(&dev->v4l2_dev);
kfree(dev);

return retval;
}

Expand All @@ -718,6 +740,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
if (dev->video_mode.alt_max_pkt_size == NULL) {
cx231xx_errdev("out of memory!\n");
cx231xx_devused &= ~(1 << nr);
v4l2_device_unregister(&dev->v4l2_dev);
kfree(dev);
return -ENOMEM;
}
Expand Down Expand Up @@ -752,6 +775,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
if (dev->vbi_mode.alt_max_pkt_size == NULL) {
cx231xx_errdev("out of memory!\n");
cx231xx_devused &= ~(1 << nr);
v4l2_device_unregister(&dev->v4l2_dev);
kfree(dev);
return -ENOMEM;
}
Expand Down Expand Up @@ -786,6 +810,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) {
cx231xx_errdev("out of memory!\n");
cx231xx_devused &= ~(1 << nr);
v4l2_device_unregister(&dev->v4l2_dev);
kfree(dev);
return -ENOMEM;
}
Expand Down Expand Up @@ -824,6 +849,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
if (dev->ts1_mode.alt_max_pkt_size == NULL) {
cx231xx_errdev("out of memory!\n");
cx231xx_devused &= ~(1 << nr);
v4l2_device_unregister(&dev->v4l2_dev);
kfree(dev);
return -ENOMEM;
}
Expand Down Expand Up @@ -876,6 +902,9 @@ static void cx231xx_usb_disconnect(struct usb_interface *interface)
if (!dev)
return;

/* delete v4l2 device */
v4l2_device_unregister(&dev->v4l2_dev);

/* wait until all current v4l2 io is finished then deallocate
resources */
mutex_lock(&dev->lock);
Expand Down
44 changes: 2 additions & 42 deletions drivers/media/video/cx231xx/cx231xx-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,18 +435,6 @@ static int attach_inform(struct i2c_client *client)
struct cx231xx *dev = bus->dev;

switch (client->addr << 1) {
case 0x32:
dprintk1(1, "attach_inform: Geminit III detected.\n");
break;
case 0x02:
dprintk1(1, "attach_inform: Acquarius detected.\n");
break;
case 0xa0:
dprintk1(1, "attach_inform: eeprom detected.\n");
break;
case 0x60:
dprintk1(1, "attach_inform: Colibri detected.\n");
break;
case 0x8e:
{
struct IR_i2c *ir = i2c_get_clientdata(client);
Expand All @@ -455,41 +443,26 @@ static int attach_inform(struct i2c_client *client)
cx231xx_set_ir(dev, ir);
break;
}
case 0x80:
case 0x88:
dprintk1(1, "attach_inform: Hammerhead detected.\n");
break;

default:
if (!dev->tuner_addr)
dev->tuner_addr = client->addr;

dprintk1(1, "attach inform: detected I2C address %x\n",
client->addr << 1);
break;
}

return 0;
}

static int detach_inform(struct i2c_client *client)
{
dprintk1(1, "i2c detach [client=%s]\n", client->name);
return 0;
}

static struct i2c_algorithm cx231xx_algo = {
.master_xfer = cx231xx_i2c_xfer,
.functionality = functionality,
};

static struct i2c_adapter cx231xx_adap_template = {
.owner = THIS_MODULE,
.class = I2C_CLASS_TV_ANALOG,
.name = "cx231xx",
.id = I2C_HW_B_CX231XX,
.algo = &cx231xx_algo,
.client_register = attach_inform,
.client_unregister = detach_inform,
};

static struct i2c_client cx231xx_client_template = {
Expand Down Expand Up @@ -535,19 +508,6 @@ void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c)
cx231xx_info(": Completed Checking for I2C devices.\n");
}

/*
* cx231xx_i2c_call_clients()
* send commands to all attached i2c devices
*/
void cx231xx_i2c_call_clients(struct cx231xx_i2c *bus, unsigned int cmd,
void *arg)
{
/* struct cx231xx *dev = bus->dev; */

BUG_ON(NULL == bus->i2c_adap.algo_data);
i2c_clients_command(&bus->i2c_adap, cmd, arg);
}

/*
* cx231xx_i2c_register()
* register i2c bus
Expand All @@ -571,7 +531,7 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus)

bus->i2c_algo.data = bus;
bus->i2c_adap.algo_data = bus;
i2c_set_adapdata(&bus->i2c_adap, bus);
i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev);
i2c_add_adapter(&bus->i2c_adap);

bus->i2c_client.adapter = &bus->i2c_adap;
Expand Down
4 changes: 0 additions & 4 deletions drivers/media/video/cx231xx/cx231xx-vbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,6 @@ vbi_buffer_setup(struct videobuf_queue *vq, unsigned int *count,
if (*count < CX231XX_MIN_BUF)
*count = CX231XX_MIN_BUF;

/* call VBI setup if required */
/* cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY, &f);
*/

return 0;
}

Expand Down
Loading

0 comments on commit b119612

Please sign in to comment.