diff options
Diffstat (limited to 'drivers/media/usb/em28xx/em28xx-audio.c')
-rw-r--r-- | drivers/media/usb/em28xx/em28xx-audio.c | 95 |
1 files changed, 53 insertions, 42 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c index e11fe46a547c..7969ddb9e2dd 100644 --- a/drivers/media/usb/em28xx/em28xx-audio.c +++ b/drivers/media/usb/em28xx/em28xx-audio.c @@ -3,7 +3,7 @@ * * Copyright (C) 2006 Markus Rechberger <mrechberger@gmail.com> * - * Copyright (C) 2007-2014 Mauro Carvalho Chehab + * Copyright (C) 2007-2016 Mauro Carvalho Chehab * - Port to work with the in-kernel driver * - Cleanups, fixes, alsa-controls, etc. * @@ -25,6 +25,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "em28xx.h" + #include <linux/kernel.h> #include <linux/usb.h> #include <linux/init.h> @@ -44,7 +46,6 @@ #include <sound/tlv.h> #include <sound/ac97_codec.h> #include <media/v4l2-common.h> -#include "em28xx.h" static int debug; module_param(debug, int, 0644); @@ -54,10 +55,10 @@ MODULE_PARM_DESC(debug, "activates debug info"); #define EM28XX_MIN_AUDIO_PACKETS 64 #define dprintk(fmt, arg...) do { \ - if (debug) \ - printk(KERN_INFO "em28xx-audio %s: " fmt, \ - __func__, ##arg); \ - } while (0) + if (debug) \ + dev_printk(KERN_DEBUG, &dev->intf->dev, \ + "video: %s: " fmt, __func__, ## arg); \ +} while (0) static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; @@ -91,7 +92,8 @@ static void em28xx_audio_isocirq(struct urb *urb) struct snd_pcm_runtime *runtime; if (dev->disconnected) { - dprintk("device disconnected while streaming. URB status=%d.\n", urb->status); + dprintk("device disconnected while streaming. URB status=%d.\n", + urb->status); atomic_set(&dev->adev.stream_started, 0); return; } @@ -164,8 +166,9 @@ static void em28xx_audio_isocirq(struct urb *urb) status = usb_submit_urb(urb, GFP_ATOMIC); if (status < 0) - em28xx_errdev("resubmit of audio urb failed (error=%i)\n", - status); + dev_err(&dev->intf->dev, + "resubmit of audio urb failed (error=%i)\n", + status); return; } @@ -182,8 +185,9 @@ static int em28xx_init_audio_isoc(struct em28xx *dev) errCode = usb_submit_urb(dev->adev.urb[i], GFP_ATOMIC); if (errCode) { - em28xx_errdev("submit of audio urb failed (error=%i)\n", - errCode); + dev_err(&dev->intf->dev, + "submit of audio urb failed (error=%i)\n", + errCode); em28xx_deinit_isoc_audio(dev); atomic_set(&dev->adev.stream_started, 0); return errCode; @@ -197,6 +201,7 @@ static int em28xx_init_audio_isoc(struct em28xx *dev) static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size) { + struct em28xx *dev = snd_pcm_substream_chip(subs); struct snd_pcm_runtime *runtime = subs->runtime; dprintk("Allocating vbuffer\n"); @@ -254,8 +259,7 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) int nonblock, ret = 0; if (!dev) { - em28xx_err("BUG: em28xx can't find device struct." - " Can't proceed with open\n"); + pr_err("em28xx-audio: BUG: em28xx can't find device struct. Can't proceed with open\n"); return -ENODEV; } @@ -275,6 +279,8 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) if (dev->adev.users == 0) { if (dev->alt == 0 || dev->is_audio_only) { + struct usb_device *udev = interface_to_usbdev(dev->intf); + if (dev->is_audio_only) /* audio is on a separate interface */ dev->alt = 1; @@ -292,7 +298,7 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) */ dprintk("changing alternate number on interface %d to %d\n", dev->ifnum, dev->alt); - usb_set_interface(dev->udev, dev->ifnum, dev->alt); + usb_set_interface(udev, dev->ifnum, dev->alt); } /* Sets volume, mute, etc */ @@ -318,7 +324,8 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) err: mutex_unlock(&dev->lock); - em28xx_err("Error while configuring em28xx mixer\n"); + dev_err(&dev->intf->dev, + "Error while configuring em28xx mixer\n"); return ret; } @@ -709,6 +716,7 @@ static const struct snd_pcm_ops snd_em28xx_pcm_capture = { static void em28xx_audio_free_urb(struct em28xx *dev) { + struct usb_device *udev = interface_to_usbdev(dev->intf); int i; for (i = 0; i < dev->adev.num_urb; i++) { @@ -717,7 +725,7 @@ static void em28xx_audio_free_urb(struct em28xx *dev) if (!urb) continue; - usb_free_coherent(dev->udev, urb->transfer_buffer_length, + usb_free_coherent(udev, urb->transfer_buffer_length, dev->adev.transfer_buffer[i], urb->transfer_dma); @@ -744,6 +752,7 @@ static int em28xx_audio_urb_init(struct em28xx *dev) { struct usb_interface *intf; struct usb_endpoint_descriptor *e, *ep = NULL; + struct usb_device *udev = interface_to_usbdev(dev->intf); int i, ep_size, interval, num_urb, npackets; int urb_size, bytes_per_transfer; u8 alt; @@ -753,10 +762,10 @@ static int em28xx_audio_urb_init(struct em28xx *dev) else alt = 7; - intf = usb_ifnum_to_if(dev->udev, dev->ifnum); + intf = usb_ifnum_to_if(udev, dev->ifnum); if (intf->num_altsetting <= alt) { - em28xx_errdev("alt %d doesn't exist on interface %d\n", + dev_err(&dev->intf->dev, "alt %d doesn't exist on interface %d\n", dev->ifnum, alt); return -ENODEV; } @@ -772,18 +781,17 @@ static int em28xx_audio_urb_init(struct em28xx *dev) } if (!ep) { - em28xx_errdev("Couldn't find an audio endpoint"); + dev_err(&dev->intf->dev, "Couldn't find an audio endpoint"); return -ENODEV; } - ep_size = em28xx_audio_ep_packet_size(dev->udev, ep); + ep_size = em28xx_audio_ep_packet_size(udev, ep); interval = 1 << (ep->bInterval - 1); - em28xx_info("Endpoint 0x%02x %s on intf %d alt %d interval = %d, size %d\n", - EM28XX_EP_AUDIO, usb_speed_string(dev->udev->speed), - dev->ifnum, alt, - interval, - ep_size); + dev_info(&dev->intf->dev, + "Endpoint 0x%02x %s on intf %d alt %d interval = %d, size %d\n", + EM28XX_EP_AUDIO, usb_speed_string(udev->speed), + dev->ifnum, alt, interval, ep_size); /* Calculate the number and size of URBs to better fit the audio samples */ @@ -820,8 +828,9 @@ static int em28xx_audio_urb_init(struct em28xx *dev) if (urb_size > ep_size * npackets) npackets = DIV_ROUND_UP(urb_size, ep_size); - em28xx_info("Number of URBs: %d, with %d packets and %d size\n", - num_urb, npackets, urb_size); + dev_info(&dev->intf->dev, + "Number of URBs: %d, with %d packets and %d size\n", + num_urb, npackets, urb_size); /* Estimate the bytes per period */ dev->adev.period = urb_size * npackets; @@ -855,18 +864,19 @@ static int em28xx_audio_urb_init(struct em28xx *dev) } dev->adev.urb[i] = urb; - buf = usb_alloc_coherent(dev->udev, npackets * ep_size, GFP_ATOMIC, + buf = usb_alloc_coherent(udev, npackets * ep_size, GFP_ATOMIC, &urb->transfer_dma); if (!buf) { - em28xx_errdev("usb_alloc_coherent failed!\n"); + dev_err(&dev->intf->dev, + "usb_alloc_coherent failed!\n"); em28xx_audio_free_urb(dev); return -ENOMEM; } dev->adev.transfer_buffer[i] = buf; - urb->dev = dev->udev; + urb->dev = udev; urb->context = dev; - urb->pipe = usb_rcvisocpipe(dev->udev, EM28XX_EP_AUDIO); + urb->pipe = usb_rcvisocpipe(udev, EM28XX_EP_AUDIO); urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; urb->transfer_buffer = buf; urb->interval = interval; @@ -886,6 +896,7 @@ static int em28xx_audio_urb_init(struct em28xx *dev) static int em28xx_audio_init(struct em28xx *dev) { struct em28xx_audio *adev = &dev->adev; + struct usb_device *udev = interface_to_usbdev(dev->intf); struct snd_pcm *pcm; struct snd_card *card; static int devnr; @@ -898,23 +909,23 @@ static int em28xx_audio_init(struct em28xx *dev) return 0; } - em28xx_info("Binding audio extension\n"); + dev_info(&dev->intf->dev, "Binding audio extension\n"); kref_get(&dev->ref); - printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus " - "Rechberger\n"); - printk(KERN_INFO - "em28xx-audio.c: Copyright (C) 2007-2014 Mauro Carvalho Chehab\n"); + dev_info(&dev->intf->dev, + "em28xx-audio.c: Copyright (C) 2006 Markus Rechberger\n"); + dev_info(&dev->intf->dev, + "em28xx-audio.c: Copyright (C) 2007-2016 Mauro Carvalho Chehab\n"); - err = snd_card_new(&dev->udev->dev, index[devnr], "Em28xx Audio", + err = snd_card_new(&dev->intf->dev, index[devnr], "Em28xx Audio", THIS_MODULE, 0, &card); if (err < 0) return err; spin_lock_init(&adev->slock); adev->sndcard = card; - adev->udev = dev->udev; + adev->udev = udev; err = snd_pcm_new(card, "Em28xx Audio", 0, 0, 1, &pcm); if (err < 0) @@ -955,7 +966,7 @@ static int em28xx_audio_init(struct em28xx *dev) if (err < 0) goto urb_free; - em28xx_info("Audio extension successfully initialized\n"); + dev_info(&dev->intf->dev, "Audio extension successfully initialized\n"); return 0; urb_free: @@ -980,7 +991,7 @@ static int em28xx_audio_fini(struct em28xx *dev) return 0; } - em28xx_info("Closing audio extension\n"); + dev_info(&dev->intf->dev, "Closing audio extension\n"); if (dev->adev.sndcard) { snd_card_disconnect(dev->adev.sndcard); @@ -1004,7 +1015,7 @@ static int em28xx_audio_suspend(struct em28xx *dev) if (dev->usb_audio_type != EM28XX_USB_AUDIO_VENDOR) return 0; - em28xx_info("Suspending audio extension\n"); + dev_info(&dev->intf->dev, "Suspending audio extension\n"); em28xx_deinit_isoc_audio(dev); atomic_set(&dev->adev.stream_started, 0); return 0; @@ -1018,7 +1029,7 @@ static int em28xx_audio_resume(struct em28xx *dev) if (dev->usb_audio_type != EM28XX_USB_AUDIO_VENDOR) return 0; - em28xx_info("Resuming audio extension\n"); + dev_info(&dev->intf->dev, "Resuming audio extension\n"); /* Nothing to do other than schedule_work() ?? */ schedule_work(&dev->adev.wq_trigger); return 0; |