diff options
Diffstat (limited to 'drivers/media/usb/cx231xx')
-rw-r--r-- | drivers/media/usb/cx231xx/cx231xx-417.c | 26 | ||||
-rw-r--r-- | drivers/media/usb/cx231xx/cx231xx-cards.c | 91 | ||||
-rw-r--r-- | drivers/media/usb/cx231xx/cx231xx-core.c | 15 | ||||
-rw-r--r-- | drivers/media/usb/cx231xx/cx231xx-dvb.c | 14 | ||||
-rw-r--r-- | drivers/media/usb/cx231xx/cx231xx-vbi.c | 2 | ||||
-rw-r--r-- | drivers/media/usb/cx231xx/cx231xx-video.c | 21 | ||||
-rw-r--r-- | drivers/media/usb/cx231xx/cx231xx.h | 4 |
7 files changed, 115 insertions, 58 deletions
diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c index 47a98a2014a5..48643b94e694 100644 --- a/drivers/media/usb/cx231xx/cx231xx-417.c +++ b/drivers/media/usb/cx231xx/cx231xx-417.c @@ -37,7 +37,7 @@ #include <media/v4l2-common.h> #include <media/v4l2-ioctl.h> #include <media/v4l2-event.h> -#include <media/cx2341x.h> +#include <media/drv-intf/cx2341x.h> #include <media/tuner.h> #define CX231xx_FIRM_IMAGE_SIZE 376836 @@ -1492,6 +1492,27 @@ static struct videobuf_queue_ops cx231xx_qops = { /* ------------------------------------------------------------------ */ +static int vidioc_cropcap(struct file *file, void *priv, + struct v4l2_cropcap *cc) +{ + struct cx231xx_fh *fh = priv; + struct cx231xx *dev = fh->dev; + bool is_50hz = dev->encodernorm.id & V4L2_STD_625_50; + + if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + + cc->bounds.left = 0; + cc->bounds.top = 0; + cc->bounds.width = dev->ts1.width; + cc->bounds.height = dev->ts1.height; + cc->defrect = cc->bounds; + cc->pixelaspect.numerator = is_50hz ? 54 : 11; + cc->pixelaspect.denominator = is_50hz ? 59 : 10; + + return 0; +} + static int vidioc_g_std(struct file *file, void *fh0, v4l2_std_id *norm) { struct cx231xx_fh *fh = file->private_data; @@ -1834,6 +1855,7 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { .vidioc_g_input = cx231xx_g_input, .vidioc_s_input = cx231xx_s_input, .vidioc_s_ctrl = vidioc_s_ctrl, + .vidioc_cropcap = vidioc_cropcap, .vidioc_querycap = cx231xx_querycap, .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, @@ -1901,7 +1923,7 @@ static int cx231xx_s_audio_sampling_freq(struct cx2341x_handler *cxhdl, u32 idx) return 0; } -static struct cx2341x_handler_ops cx231xx_ops = { +static const struct cx2341x_handler_ops cx231xx_ops = { /* needed for the video clock freq */ .s_audio_sampling_freq = cx231xx_s_audio_sampling_freq, /* needed for setting up the video resolution */ diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c index 4a117a58c39a..620b83d03f75 100644 --- a/drivers/media/usb/cx231xx/cx231xx-cards.c +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c @@ -30,7 +30,7 @@ #include <media/tveeprom.h> #include <media/v4l2-common.h> -#include <media/cx25840.h> +#include <media/drv-intf/cx25840.h> #include "dvb-usb-ids.h" #include "xc5000.h" #include "tda18271.h" @@ -352,7 +352,7 @@ struct cx231xx_board cx231xx_boards[] = { .agc_analog_digital_select_gpio = 0x0c, .gpio_pin_status_mask = 0x4001000, .tuner_i2c_master = I2C_1_MUX_1, - .demod_i2c_master = I2C_2, + .demod_i2c_master = I2C_1_MUX_1, .has_dvb = 1, .demod_addr = 0x0e, .norm = V4L2_STD_NTSC, @@ -713,7 +713,7 @@ struct cx231xx_board cx231xx_boards[] = { .agc_analog_digital_select_gpio = 0x0c, .gpio_pin_status_mask = 0x4001000, .tuner_i2c_master = I2C_1_MUX_3, - .demod_i2c_master = I2C_2, + .demod_i2c_master = I2C_1_MUX_3, .has_dvb = 1, .demod_addr = 0x0e, .norm = V4L2_STD_PAL, @@ -752,7 +752,7 @@ struct cx231xx_board cx231xx_boards[] = { .agc_analog_digital_select_gpio = 0x0c, .gpio_pin_status_mask = 0x4001000, .tuner_i2c_master = I2C_1_MUX_3, - .demod_i2c_master = I2C_2, + .demod_i2c_master = I2C_1_MUX_3, .has_dvb = 1, .demod_addr = 0x0e, .norm = V4L2_STD_PAL, @@ -791,7 +791,7 @@ struct cx231xx_board cx231xx_boards[] = { .agc_analog_digital_select_gpio = 0x0c, .gpio_pin_status_mask = 0x4001000, .tuner_i2c_master = I2C_1_MUX_3, - .demod_i2c_master = I2C_2, + .demod_i2c_master = I2C_1_MUX_3, .has_dvb = 1, .demod_addr = 0x0e, .norm = V4L2_STD_NTSC, @@ -1172,6 +1172,7 @@ static void cx231xx_unregister_media_device(struct cx231xx *dev) #ifdef CONFIG_MEDIA_CONTROLLER if (dev->media_dev) { media_device_unregister(dev->media_dev); + media_device_cleanup(dev->media_dev); kfree(dev->media_dev); dev->media_dev = NULL; } @@ -1185,8 +1186,6 @@ static void cx231xx_unregister_media_device(struct cx231xx *dev) */ void cx231xx_release_resources(struct cx231xx *dev) { - cx231xx_unregister_media_device(dev); - cx231xx_release_analog_resources(dev); cx231xx_remove_from_devlist(dev); @@ -1199,22 +1198,23 @@ void cx231xx_release_resources(struct cx231xx *dev) /* delete v4l2 device */ v4l2_device_unregister(&dev->v4l2_dev); + cx231xx_unregister_media_device(dev); + usb_put_dev(dev->udev); /* Mark device as unused */ clear_bit(dev->devno, &cx231xx_devused); } -static void cx231xx_media_device_register(struct cx231xx *dev, - struct usb_device *udev) +static int cx231xx_media_device_init(struct cx231xx *dev, + struct usb_device *udev) { #ifdef CONFIG_MEDIA_CONTROLLER struct media_device *mdev; - int ret; mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); if (!mdev) - return; + return -ENOMEM; mdev->dev = dev->dev; strlcpy(mdev->model, dev->board.name, sizeof(mdev->model)); @@ -1224,35 +1224,30 @@ static void cx231xx_media_device_register(struct cx231xx *dev, mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); mdev->driver_version = LINUX_VERSION_CODE; - ret = media_device_register(mdev); - if (ret) { - dev_err(dev->dev, - "Couldn't create a media device. Error: %d\n", - ret); - kfree(mdev); - return; - } + media_device_init(mdev); dev->media_dev = mdev; #endif + return 0; } -static void cx231xx_create_media_graph(struct cx231xx *dev) +static int cx231xx_create_media_graph(struct cx231xx *dev) { #ifdef CONFIG_MEDIA_CONTROLLER struct media_device *mdev = dev->media_dev; struct media_entity *entity; struct media_entity *tuner = NULL, *decoder = NULL; + int ret; if (!mdev) - return; + return 0; media_device_for_each_entity(entity, mdev) { - switch (entity->type) { - case MEDIA_ENT_T_V4L2_SUBDEV_TUNER: + switch (entity->function) { + case MEDIA_ENT_F_TUNER: tuner = entity; break; - case MEDIA_ENT_T_V4L2_SUBDEV_DECODER: + case MEDIA_ENT_F_ATV_DECODER: decoder = entity; break; } @@ -1261,16 +1256,24 @@ static void cx231xx_create_media_graph(struct cx231xx *dev) /* Analog setup, using tuner as a link */ if (!decoder) - return; + return 0; - if (tuner) - media_entity_create_link(tuner, 0, decoder, 0, - MEDIA_LNK_FL_ENABLED); - media_entity_create_link(decoder, 1, &dev->vdev.entity, 0, - MEDIA_LNK_FL_ENABLED); - media_entity_create_link(decoder, 2, &dev->vbi_dev.entity, 0, - MEDIA_LNK_FL_ENABLED); + if (tuner) { + ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0, + MEDIA_LNK_FL_ENABLED); + if (ret < 0) + return ret; + } + ret = media_create_pad_link(decoder, 1, &dev->vdev.entity, 0, + MEDIA_LNK_FL_ENABLED); + if (ret < 0) + return ret; + ret = media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0, + MEDIA_LNK_FL_ENABLED); + if (ret < 0) + return ret; #endif + return 0; } /* @@ -1660,8 +1663,12 @@ static int cx231xx_usb_probe(struct usb_interface *interface, /* save our data pointer in this interface device */ usb_set_intfdata(interface, dev); - /* Register the media controller */ - cx231xx_media_device_register(dev, udev); + /* Initialize the media controller */ + retval = cx231xx_media_device_init(dev, udev); + if (retval) { + dev_err(d, "cx231xx_media_device_init failed\n"); + goto err_media_init; + } /* Create v4l2 device */ #ifdef CONFIG_MEDIA_CONTROLLER @@ -1732,9 +1739,19 @@ static int cx231xx_usb_probe(struct usb_interface *interface, /* load other modules required */ request_modules(dev); - cx231xx_create_media_graph(dev); + retval = cx231xx_create_media_graph(dev); + if (retval < 0) + goto done; + +#ifdef CONFIG_MEDIA_CONTROLLER + retval = media_device_register(dev->media_dev); +#endif + +done: + if (retval < 0) + cx231xx_release_resources(dev); + return retval; - return 0; err_video_alt: /* cx231xx_uninit_dev: */ cx231xx_close_extension(dev); @@ -1746,6 +1763,8 @@ err_video_alt: err_init: v4l2_device_unregister(&dev->v4l2_dev); err_v4l2: + cx231xx_unregister_media_device(dev); +err_media_init: usb_set_intfdata(interface, NULL); err_if: usb_put_dev(udev); diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c index a2fd49b6be83..f497888d94bf 100644 --- a/drivers/media/usb/cx231xx/cx231xx-core.c +++ b/drivers/media/usb/cx231xx/cx231xx-core.c @@ -914,6 +914,7 @@ EXPORT_SYMBOL_GPL(cx231xx_uninit_isoc); */ void cx231xx_uninit_bulk(struct cx231xx *dev) { + struct cx231xx_dmaqueue *dma_q = &dev->video_mode.vidq; struct urb *urb; int i; @@ -931,7 +932,7 @@ void cx231xx_uninit_bulk(struct cx231xx *dev) if (dev->video_mode.bulk_ctl.transfer_buffer[i]) { usb_free_coherent(dev->udev, urb->transfer_buffer_length, - dev->video_mode.isoc_ctl. + dev->video_mode.bulk_ctl. transfer_buffer[i], urb->transfer_dma); } @@ -943,10 +944,12 @@ void cx231xx_uninit_bulk(struct cx231xx *dev) kfree(dev->video_mode.bulk_ctl.urb); kfree(dev->video_mode.bulk_ctl.transfer_buffer); + kfree(dma_q->p_left_data); dev->video_mode.bulk_ctl.urb = NULL; dev->video_mode.bulk_ctl.transfer_buffer = NULL; dev->video_mode.bulk_ctl.num_bufs = 0; + dma_q->p_left_data = NULL; if (dev->mode_tv == 0) cx231xx_capture_start(dev, 0, Raw_Video); @@ -1196,6 +1199,16 @@ int cx231xx_init_bulk(struct cx231xx *dev, int max_packets, sb_size, cx231xx_bulk_irq_callback, dma_q); } + /* clear halt */ + rc = usb_clear_halt(dev->udev, dev->video_mode.bulk_ctl.urb[0]->pipe); + if (rc < 0) { + dev_err(dev->dev, + "failed to clear USB bulk endpoint stall/halt condition (error=%i)\n", + rc); + cx231xx_uninit_bulk(dev); + return rc; + } + init_waitqueue_head(&dma_q->wq); /* submit urbs and enables IRQ */ diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c index 66ee161fc7ba..b8d5b2be9293 100644 --- a/drivers/media/usb/cx231xx/cx231xx-dvb.c +++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c @@ -551,10 +551,14 @@ static int register_dvb(struct cx231xx_dvb *dvb, /* register network adapter */ dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); - dvb_create_media_graph(&dvb->adapter); + result = dvb_create_media_graph(&dvb->adapter, false); + if (result < 0) + goto fail_create_graph; return 0; +fail_create_graph: + dvb_net_release(&dvb->net); fail_fe_conn: dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); fail_fe_mem: @@ -725,7 +729,7 @@ static int dvb_init(struct cx231xx *dev) dev->dvb->frontend = dvb_attach(lgdt3305_attach, &hcw_lgdt3305_config, - tuner_i2c); + demod_i2c); if (dev->dvb->frontend == NULL) { dev_err(dev->dev, @@ -746,7 +750,7 @@ static int dvb_init(struct cx231xx *dev) dev->dvb->frontend = dvb_attach(si2165_attach, &hauppauge_930C_HD_1113xx_si2165_config, - tuner_i2c + demod_i2c ); if (dev->dvb->frontend == NULL) { @@ -779,7 +783,7 @@ static int dvb_init(struct cx231xx *dev) dev->dvb->frontend = dvb_attach(si2165_attach, &pctv_quatro_stick_1114xx_si2165_config, - tuner_i2c + demod_i2c ); if (dev->dvb->frontend == NULL) { @@ -835,7 +839,7 @@ static int dvb_init(struct cx231xx *dev) dev->dvb->frontend = dvb_attach(lgdt3306a_attach, &hauppauge_955q_lgdt3306a_config, - tuner_i2c + demod_i2c ); if (dev->dvb->frontend == NULL) { diff --git a/drivers/media/usb/cx231xx/cx231xx-vbi.c b/drivers/media/usb/cx231xx/cx231xx-vbi.c index a08014d20a5c..15bb573b78ac 100644 --- a/drivers/media/usb/cx231xx/cx231xx-vbi.c +++ b/drivers/media/usb/cx231xx/cx231xx-vbi.c @@ -32,7 +32,7 @@ #include <media/v4l2-common.h> #include <media/v4l2-ioctl.h> -#include <media/msp3400.h> +#include <media/drv-intf/msp3400.h> #include <media/tuner.h> #include "cx231xx-vbi.h" diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c index d0d8f08e37c8..9b88cd8127ac 100644 --- a/drivers/media/usb/cx231xx/cx231xx-video.c +++ b/drivers/media/usb/cx231xx/cx231xx-video.c @@ -36,7 +36,7 @@ #include <media/v4l2-common.h> #include <media/v4l2-ioctl.h> #include <media/v4l2-event.h> -#include <media/msp3400.h> +#include <media/drv-intf/msp3400.h> #include <media/tuner.h> #include "dvb_frontend.h" @@ -106,7 +106,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev) struct media_device *mdev = dev->media_dev; struct media_entity *entity, *decoder = NULL, *source; struct media_link *link, *found_link = NULL; - int i, ret, active_links = 0; + int ret, active_links = 0; if (!mdev) return 0; @@ -119,7 +119,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev) * this should be enough for the actual needs. */ media_device_for_each_entity(entity, mdev) { - if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) { + if (entity->function == MEDIA_ENT_F_ATV_DECODER) { decoder = entity; break; } @@ -127,8 +127,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev) if (!decoder) return 0; - for (i = 0; i < decoder->num_links; i++) { - link = &decoder->links[i]; + list_for_each_entry(link, &decoder->links, list) { if (link->sink->entity == decoder) { found_link = link; if (link->flags & MEDIA_LNK_FL_ENABLED) @@ -141,11 +140,10 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev) return 0; source = found_link->source->entity; - for (i = 0; i < source->num_links; i++) { + list_for_each_entry(link, &source->links, list) { struct media_entity *sink; int flags = 0; - link = &source->links[i]; sink = link->sink->entity; if (sink == entity) @@ -1444,6 +1442,7 @@ static int vidioc_cropcap(struct file *file, void *priv, { struct cx231xx_fh *fh = priv; struct cx231xx *dev = fh->dev; + bool is_50hz = dev->norm & V4L2_STD_625_50; if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; @@ -1453,8 +1452,8 @@ static int vidioc_cropcap(struct file *file, void *priv, cc->bounds.width = dev->width; cc->bounds.height = dev->height; cc->defrect = cc->bounds; - cc->pixelaspect.numerator = 54; /* 4:3 FIXME: remove magic numbers */ - cc->pixelaspect.denominator = 59; + cc->pixelaspect.numerator = is_50hz ? 54 : 11; + cc->pixelaspect.denominator = is_50hz ? 59 : 10; return 0; } @@ -2176,7 +2175,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) cx231xx_vdev_init(dev, &dev->vdev, &cx231xx_video_template, "video"); #if defined(CONFIG_MEDIA_CONTROLLER) dev->video_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad, 0); + ret = media_entity_pads_init(&dev->vdev.entity, 1, &dev->video_pad); if (ret < 0) dev_err(dev->dev, "failed to initialize video media entity!\n"); #endif @@ -2203,7 +2202,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) #if defined(CONFIG_MEDIA_CONTROLLER) dev->vbi_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad, 0); + ret = media_entity_pads_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad); if (ret < 0) dev_err(dev->dev, "failed to initialize vbi media entity!\n"); #endif diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h index 54790fbe8fdc..ec6d3f5bc36d 100644 --- a/drivers/media/usb/cx231xx/cx231xx.h +++ b/drivers/media/usb/cx231xx/cx231xx.h @@ -30,14 +30,14 @@ #include <linux/mutex.h> #include <linux/usb.h> -#include <media/cx2341x.h> +#include <media/drv-intf/cx2341x.h> #include <media/videobuf-vmalloc.h> #include <media/v4l2-device.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-fh.h> #include <media/rc-core.h> -#include <media/ir-kbd-i2c.h> +#include <media/i2c/ir-kbd-i2c.h> #include <media/videobuf-dvb.h> #include "cx231xx-reg.h" |