diff options
Diffstat (limited to 'drivers/media/usb/em28xx/em28xx-video.c')
-rw-r--r-- | drivers/media/usb/em28xx/em28xx-video.c | 163 |
1 files changed, 93 insertions, 70 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index 1f7fa059eb34..8d93100334ea 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c @@ -26,6 +26,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "em28xx.h" + #include <linux/init.h> #include <linux/list.h> #include <linux/module.h> @@ -37,7 +39,6 @@ #include <linux/mutex.h> #include <linux/slab.h> -#include "em28xx.h" #include "em28xx-v4l.h" #include <media/v4l2-common.h> #include <media/v4l2-ioctl.h> @@ -63,18 +64,17 @@ static int alt; module_param(alt, int, 0644); MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint"); -#define em28xx_videodbg(fmt, arg...) do {\ - if (video_debug) \ - printk(KERN_INFO "%s %s :"fmt, \ - dev->name, __func__ , ##arg); } while (0) +#define em28xx_videodbg(fmt, arg...) do { \ + if (video_debug) \ + dev_printk(KERN_DEBUG, &dev->intf->dev, \ + "video: %s: " fmt, __func__, ## arg); \ +} while (0) -#define em28xx_isocdbg(fmt, arg...) \ -do {\ - if (isoc_debug) { \ - printk(KERN_INFO "%s %s :"fmt, \ - dev->name, __func__ , ##arg); \ - } \ - } while (0) +#define em28xx_isocdbg(fmt, arg...) do {\ + if (isoc_debug) \ + dev_printk(KERN_DEBUG, &dev->intf->dev, \ + "isoc: %s: " fmt, __func__, ## arg); \ +} while (0) MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC " - v4l2 interface"); @@ -360,6 +360,7 @@ static int em28xx_resolution_set(struct em28xx *dev) static int em28xx_set_alternate(struct em28xx *dev) { struct em28xx_v4l2 *v4l2 = dev->v4l2; + struct usb_device *udev = interface_to_usbdev(dev->intf); int errCode; int i; unsigned int min_pkt_size = v4l2->width * 2 + 4; @@ -411,10 +412,11 @@ set_alt: } em28xx_videodbg("setting alternate %d with wMaxPacketSize=%u\n", dev->alt, dev->max_pkt_size); - errCode = usb_set_interface(dev->udev, dev->ifnum, dev->alt); + errCode = usb_set_interface(udev, dev->ifnum, dev->alt); if (errCode < 0) { - em28xx_errdev("cannot change alternate number to %d (error=%i)\n", - dev->alt, errCode); + dev_err(&dev->intf->dev, + "cannot change alternate number to %d (error=%i)\n", + dev->alt, errCode); return errCode; } return 0; @@ -505,8 +507,7 @@ static void em28xx_copy_video(struct em28xx *dev, if ((char *)startwrite + lencopy > (char *)buf->vb_buf + buf->length) { - em28xx_isocdbg("Overflow of %zu bytes past buffer end" - "(2)\n", + em28xx_isocdbg("Overflow of %zu bytes past buffer end(2)\n", ((char *)startwrite + lencopy) - ((char *)buf->vb_buf + buf->length)); lencopy = remain = (char *)buf->vb_buf + buf->length - @@ -926,10 +927,11 @@ static int em28xx_enable_analog_tuner(struct em28xx *dev) ret = media_entity_setup_link(link, flags); if (ret) { - pr_err("Couldn't change link %s->%s to %s. Error %d\n", - source->name, sink->name, - flags ? "enabled" : "disabled", - ret); + dev_err(&dev->intf->dev, + "Couldn't change link %s->%s to %s. Error %d\n", + source->name, sink->name, + flags ? "enabled" : "disabled", + ret); return ret; } else em28xx_videodbg("link %s->%s was %s\n", @@ -957,14 +959,16 @@ static void em28xx_v4l2_create_entities(struct em28xx *dev) v4l2->video_pad.flags = MEDIA_PAD_FL_SINK; ret = media_entity_pads_init(&v4l2->vdev.entity, 1, &v4l2->video_pad); if (ret < 0) - pr_err("failed to initialize video media entity!\n"); + dev_err(&dev->intf->dev, + "failed to initialize video media entity!\n"); if (em28xx_vbi_supported(dev)) { v4l2->vbi_pad.flags = MEDIA_PAD_FL_SINK; ret = media_entity_pads_init(&v4l2->vbi_dev.entity, 1, &v4l2->vbi_pad); if (ret < 0) - pr_err("failed to initialize vbi media entity!\n"); + dev_err(&dev->intf->dev, + "failed to initialize vbi media entity!\n"); } /* Webcams don't have input connectors */ @@ -997,11 +1001,13 @@ static void em28xx_v4l2_create_entities(struct em28xx *dev) ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]); if (ret < 0) - pr_err("failed to initialize input pad[%d]!\n", i); + dev_err(&dev->intf->dev, + "failed to initialize input pad[%d]!\n", i); ret = media_device_register_entity(dev->media_dev, ent); if (ret < 0) - pr_err("failed to register input entity %d!\n", i); + dev_err(&dev->intf->dev, + "failed to register input entity %d!\n", i); } #endif } @@ -1854,10 +1860,11 @@ static int vidioc_querycap(struct file *file, void *priv, struct video_device *vdev = video_devdata(file); struct em28xx *dev = video_drvdata(file); struct em28xx_v4l2 *v4l2 = dev->v4l2; + struct usb_device *udev = interface_to_usbdev(dev->intf); strlcpy(cap->driver, "em28xx", sizeof(cap->driver)); strlcpy(cap->card, em28xx_boards[dev->model].name, sizeof(cap->card)); - usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); + usb_make_path(udev, cap->bus_info, sizeof(cap->bus_info)); if (vdev->vfl_type == VFL_TYPE_GRABBER) cap->device_caps = V4L2_CAP_READWRITE | @@ -2048,8 +2055,9 @@ static int em28xx_v4l2_open(struct file *filp) ret = v4l2_fh_open(filp); if (ret) { - em28xx_errdev("%s: v4l2_fh_open() returned error %d\n", - __func__, ret); + dev_err(&dev->intf->dev, + "%s: v4l2_fh_open() returned error %d\n", + __func__, ret); mutex_unlock(&dev->lock); return ret; } @@ -2103,7 +2111,7 @@ static int em28xx_v4l2_fini(struct em28xx *dev) if (v4l2 == NULL) return 0; - em28xx_info("Closing video extension\n"); + dev_info(&dev->intf->dev, "Closing video extension\n"); mutex_lock(&dev->lock); @@ -2114,18 +2122,18 @@ static int em28xx_v4l2_fini(struct em28xx *dev) em28xx_v4l2_media_release(dev); if (video_is_registered(&v4l2->radio_dev)) { - em28xx_info("V4L2 device %s deregistered\n", - video_device_node_name(&v4l2->radio_dev)); + dev_info(&dev->intf->dev, "V4L2 device %s deregistered\n", + video_device_node_name(&v4l2->radio_dev)); video_unregister_device(&v4l2->radio_dev); } if (video_is_registered(&v4l2->vbi_dev)) { - em28xx_info("V4L2 device %s deregistered\n", - video_device_node_name(&v4l2->vbi_dev)); + dev_info(&dev->intf->dev, "V4L2 device %s deregistered\n", + video_device_node_name(&v4l2->vbi_dev)); video_unregister_device(&v4l2->vbi_dev); } if (video_is_registered(&v4l2->vdev)) { - em28xx_info("V4L2 device %s deregistered\n", - video_device_node_name(&v4l2->vdev)); + dev_info(&dev->intf->dev, "V4L2 device %s deregistered\n", + video_device_node_name(&v4l2->vdev)); video_unregister_device(&v4l2->vdev); } @@ -2154,7 +2162,7 @@ static int em28xx_v4l2_suspend(struct em28xx *dev) if (!dev->has_video) return 0; - em28xx_info("Suspending video extension\n"); + dev_info(&dev->intf->dev, "Suspending video extension\n"); em28xx_stop_urbs(dev); return 0; } @@ -2167,7 +2175,7 @@ static int em28xx_v4l2_resume(struct em28xx *dev) if (!dev->has_video) return 0; - em28xx_info("Resuming video extension\n"); + dev_info(&dev->intf->dev, "Resuming video extension\n"); /* what do we do here */ return 0; } @@ -2181,6 +2189,7 @@ static int em28xx_v4l2_close(struct file *filp) { struct em28xx *dev = video_drvdata(filp); struct em28xx_v4l2 *v4l2 = dev->v4l2; + struct usb_device *udev = interface_to_usbdev(dev->intf); int errCode; em28xx_videodbg("users=%d\n", v4l2->users); @@ -2202,10 +2211,11 @@ static int em28xx_v4l2_close(struct file *filp) /* set alternate 0 */ dev->alt = 0; em28xx_videodbg("setting alternate 0\n"); - errCode = usb_set_interface(dev->udev, 0, 0); + errCode = usb_set_interface(udev, 0, 0); if (errCode < 0) { - em28xx_errdev("cannot change alternate number to " - "0 (error=%i)\n", errCode); + dev_err(&dev->intf->dev, + "cannot change alternate number to 0 (error=%i)\n", + errCode); } } @@ -2338,7 +2348,7 @@ static void em28xx_vdev_init(struct em28xx *dev, vfd->tvnorms = 0; snprintf(vfd->name, sizeof(vfd->name), "%s %s", - dev->name, type_name); + dev_name(&dev->intf->dev), type_name); video_set_drvdata(vfd, dev); } @@ -2422,13 +2432,12 @@ static int em28xx_v4l2_init(struct em28xx *dev) return 0; } - em28xx_info("Registering V4L2 extension\n"); + dev_info(&dev->intf->dev, "Registering V4L2 extension\n"); mutex_lock(&dev->lock); v4l2 = kzalloc(sizeof(struct em28xx_v4l2), GFP_KERNEL); - if (v4l2 == NULL) { - em28xx_info("em28xx_v4l: memory allocation failed\n"); + if (!v4l2) { mutex_unlock(&dev->lock); return -ENOMEM; } @@ -2439,9 +2448,10 @@ static int em28xx_v4l2_init(struct em28xx *dev) #ifdef CONFIG_MEDIA_CONTROLLER v4l2->v4l2_dev.mdev = dev->media_dev; #endif - ret = v4l2_device_register(&dev->udev->dev, &v4l2->v4l2_dev); + ret = v4l2_device_register(&dev->intf->dev, &v4l2->v4l2_dev); if (ret < 0) { - em28xx_errdev("Call to v4l2_device_register() failed!\n"); + dev_err(&dev->intf->dev, + "Call to v4l2_device_register() failed!\n"); goto err; } @@ -2525,8 +2535,9 @@ static int em28xx_v4l2_init(struct em28xx *dev) /* Configure audio */ ret = em28xx_audio_setup(dev); if (ret < 0) { - em28xx_errdev("%s: Error while setting audio - error [%d]!\n", - __func__, ret); + dev_err(&dev->intf->dev, + "%s: Error while setting audio - error [%d]!\n", + __func__, ret); goto unregister_dev; } if (dev->audio_mode.ac97 != EM28XX_NO_AC97) { @@ -2553,16 +2564,18 @@ static int em28xx_v4l2_init(struct em28xx *dev) /* Send a reset to other chips via gpio */ ret = em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xf7); if (ret < 0) { - em28xx_errdev("%s: em28xx_write_reg - msp34xx(1) failed! error [%d]\n", - __func__, ret); + dev_err(&dev->intf->dev, + "%s: em28xx_write_reg - msp34xx(1) failed! error [%d]\n", + __func__, ret); goto unregister_dev; } msleep(3); ret = em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xff); if (ret < 0) { - em28xx_errdev("%s: em28xx_write_reg - msp34xx(2) failed! error [%d]\n", - __func__, ret); + dev_err(&dev->intf->dev, + "%s: em28xx_write_reg - msp34xx(2) failed! error [%d]\n", + __func__, ret); goto unregister_dev; } msleep(3); @@ -2663,8 +2676,8 @@ static int em28xx_v4l2_init(struct em28xx *dev) ret = video_register_device(&v4l2->vdev, VFL_TYPE_GRABBER, video_nr[dev->devno]); if (ret) { - em28xx_errdev("unable to register video device (error=%i).\n", - ret); + dev_err(&dev->intf->dev, + "unable to register video device (error=%i).\n", ret); goto unregister_dev; } @@ -2693,7 +2706,8 @@ static int em28xx_v4l2_init(struct em28xx *dev) ret = video_register_device(&v4l2->vbi_dev, VFL_TYPE_VBI, vbi_nr[dev->devno]); if (ret < 0) { - em28xx_errdev("unable to register vbi device\n"); + dev_err(&dev->intf->dev, + "unable to register vbi device\n"); goto unregister_dev; } } @@ -2704,11 +2718,13 @@ static int em28xx_v4l2_init(struct em28xx *dev) ret = video_register_device(&v4l2->radio_dev, VFL_TYPE_RADIO, radio_nr[dev->devno]); if (ret < 0) { - em28xx_errdev("can't register radio device\n"); + dev_err(&dev->intf->dev, + "can't register radio device\n"); goto unregister_dev; } - em28xx_info("Registered radio device as %s\n", - video_device_node_name(&v4l2->radio_dev)); + dev_info(&dev->intf->dev, + "Registered radio device as %s\n", + video_device_node_name(&v4l2->radio_dev)); } /* Init entities at the Media Controller */ @@ -2717,18 +2733,21 @@ static int em28xx_v4l2_init(struct em28xx *dev) #ifdef CONFIG_MEDIA_CONTROLLER ret = v4l2_mc_create_media_graph(dev->media_dev); if (ret) { - em28xx_errdev("failed to create media graph\n"); + dev_err(&dev->intf->dev, + "failed to create media graph\n"); em28xx_v4l2_media_release(dev); goto unregister_dev; } #endif - em28xx_info("V4L2 video device registered as %s\n", - video_device_node_name(&v4l2->vdev)); + dev_info(&dev->intf->dev, + "V4L2 video device registered as %s\n", + video_device_node_name(&v4l2->vdev)); if (video_is_registered(&v4l2->vbi_dev)) - em28xx_info("V4L2 VBI device registered as %s\n", - video_device_node_name(&v4l2->vbi_dev)); + dev_info(&dev->intf->dev, + "V4L2 VBI device registered as %s\n", + video_device_node_name(&v4l2->vbi_dev)); /* Save some power by putting tuner to sleep */ v4l2_device_call_all(&v4l2->v4l2_dev, 0, core, s_power, 0); @@ -2736,7 +2755,8 @@ static int em28xx_v4l2_init(struct em28xx *dev) /* initialize videobuf2 stuff */ em28xx_vb2_setup(dev); - em28xx_info("V4L2 extension successfully initialized\n"); + dev_info(&dev->intf->dev, + "V4L2 extension successfully initialized\n"); kref_get(&dev->ref); @@ -2745,18 +2765,21 @@ static int em28xx_v4l2_init(struct em28xx *dev) unregister_dev: if (video_is_registered(&v4l2->radio_dev)) { - em28xx_info("V4L2 device %s deregistered\n", - video_device_node_name(&v4l2->radio_dev)); + dev_info(&dev->intf->dev, + "V4L2 device %s deregistered\n", + video_device_node_name(&v4l2->radio_dev)); video_unregister_device(&v4l2->radio_dev); } if (video_is_registered(&v4l2->vbi_dev)) { - em28xx_info("V4L2 device %s deregistered\n", - video_device_node_name(&v4l2->vbi_dev)); + dev_info(&dev->intf->dev, + "V4L2 device %s deregistered\n", + video_device_node_name(&v4l2->vbi_dev)); video_unregister_device(&v4l2->vbi_dev); } if (video_is_registered(&v4l2->vdev)) { - em28xx_info("V4L2 device %s deregistered\n", - video_device_node_name(&v4l2->vdev)); + dev_info(&dev->intf->dev, + "V4L2 device %s deregistered\n", + video_device_node_name(&v4l2->vdev)); video_unregister_device(&v4l2->vdev); } |