aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorFrank Schaefer <fschaefer.oss@googlemail.com>2014-09-13 04:52:20 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-09-23 15:13:41 -0400
commitc5874208ff78a5180ef0456caa117704983f3a45 (patch)
tree48754c1457f1b8fbf786d6112c87f4d48531099c /drivers
parent60a24ba03c5dcd51a754cb45e7d65753126f58ce (diff)
[media] em28xx: simplify usb audio class handling
As far as we know devices can either have audio class or vendor class usb interfaces but not both at the same time. Even if both interface types could be provided by devices at the same time, the current code is totally broken for that case. So clean up and simplify the usb audio class handling by replacing fields "has_audio_class" (device has usb audio class compliant interface) and "has_alsa_audio" (device has vendor audio interface) in struct em28xx with a single enum em28xx_usb_audio_type. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/usb/em28xx/em28xx-audio.c8
-rw-r--r--drivers/media/usb/em28xx/em28xx-cards.c30
-rw-r--r--drivers/media/usb/em28xx/em28xx-core.c8
-rw-r--r--drivers/media/usb/em28xx/em28xx.h9
4 files changed, 31 insertions, 24 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c
index e881ef7b6445..90c7a83989d1 100644
--- a/drivers/media/usb/em28xx/em28xx-audio.c
+++ b/drivers/media/usb/em28xx/em28xx-audio.c
@@ -893,7 +893,7 @@ static int em28xx_audio_init(struct em28xx *dev)
893 static int devnr; 893 static int devnr;
894 int err; 894 int err;
895 895
896 if (!dev->has_alsa_audio) { 896 if (dev->usb_audio_type != EM28XX_USB_AUDIO_VENDOR) {
897 /* This device does not support the extension (in this case 897 /* This device does not support the extension (in this case
898 the device is expecting the snd-usb-audio module or 898 the device is expecting the snd-usb-audio module or
899 doesn't have analog audio support at all) */ 899 doesn't have analog audio support at all) */
@@ -975,7 +975,7 @@ static int em28xx_audio_fini(struct em28xx *dev)
975 if (dev == NULL) 975 if (dev == NULL)
976 return 0; 976 return 0;
977 977
978 if (!dev->has_alsa_audio) { 978 if (dev->usb_audio_type != EM28XX_USB_AUDIO_VENDOR) {
979 /* This device does not support the extension (in this case 979 /* This device does not support the extension (in this case
980 the device is expecting the snd-usb-audio module or 980 the device is expecting the snd-usb-audio module or
981 doesn't have analog audio support at all) */ 981 doesn't have analog audio support at all) */
@@ -1003,7 +1003,7 @@ static int em28xx_audio_suspend(struct em28xx *dev)
1003 if (dev == NULL) 1003 if (dev == NULL)
1004 return 0; 1004 return 0;
1005 1005
1006 if (!dev->has_alsa_audio) 1006 if (dev->usb_audio_type != EM28XX_USB_AUDIO_VENDOR)
1007 return 0; 1007 return 0;
1008 1008
1009 em28xx_info("Suspending audio extension"); 1009 em28xx_info("Suspending audio extension");
@@ -1017,7 +1017,7 @@ static int em28xx_audio_resume(struct em28xx *dev)
1017 if (dev == NULL) 1017 if (dev == NULL)
1018 return 0; 1018 return 0;
1019 1019
1020 if (!dev->has_alsa_audio) 1020 if (dev->usb_audio_type != EM28XX_USB_AUDIO_VENDOR)
1021 return 0; 1021 return 0;
1022 1022
1023 em28xx_info("Resuming audio extension"); 1023 em28xx_info("Resuming audio extension");
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
index 582c1e192472..f1425882a843 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -2931,9 +2931,9 @@ static void request_module_async(struct work_struct *work)
2931#if defined(CONFIG_MODULES) && defined(MODULE) 2931#if defined(CONFIG_MODULES) && defined(MODULE)
2932 if (dev->has_video) 2932 if (dev->has_video)
2933 request_module("em28xx-v4l"); 2933 request_module("em28xx-v4l");
2934 if (dev->has_audio_class) 2934 if (dev->usb_audio_type == EM28XX_USB_AUDIO_CLASS)
2935 request_module("snd-usb-audio"); 2935 request_module("snd-usb-audio");
2936 else if (dev->has_alsa_audio) 2936 else if (dev->usb_audio_type == EM28XX_USB_AUDIO_VENDOR)
2937 request_module("em28xx-alsa"); 2937 request_module("em28xx-alsa");
2938 if (dev->board.has_dvb) 2938 if (dev->board.has_dvb)
2939 request_module("em28xx-dvb"); 2939 request_module("em28xx-dvb");
@@ -3180,7 +3180,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3180 struct usb_device *udev; 3180 struct usb_device *udev;
3181 struct em28xx *dev = NULL; 3181 struct em28xx *dev = NULL;
3182 int retval; 3182 int retval;
3183 bool has_audio = false, has_video = false, has_dvb = false; 3183 bool has_vendor_audio = false, has_video = false, has_dvb = false;
3184 int i, nr, try_bulk; 3184 int i, nr, try_bulk;
3185 const int ifnum = interface->altsetting[0].desc.bInterfaceNumber; 3185 const int ifnum = interface->altsetting[0].desc.bInterfaceNumber;
3186 char *speed; 3186 char *speed;
@@ -3262,7 +3262,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3262 break; 3262 break;
3263 case 0x83: 3263 case 0x83:
3264 if (usb_endpoint_xfer_isoc(e)) { 3264 if (usb_endpoint_xfer_isoc(e)) {
3265 has_audio = true; 3265 has_vendor_audio = true;
3266 } else { 3266 } else {
3267 printk(KERN_INFO DRIVER_NAME 3267 printk(KERN_INFO DRIVER_NAME
3268 ": error: skipping audio endpoint 0x83, because it uses bulk transfers !\n"); 3268 ": error: skipping audio endpoint 0x83, because it uses bulk transfers !\n");
@@ -3318,7 +3318,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3318 } 3318 }
3319 } 3319 }
3320 3320
3321 if (!(has_audio || has_video || has_dvb)) { 3321 if (!(has_vendor_audio || has_video || has_dvb)) {
3322 retval = -ENODEV; 3322 retval = -ENODEV;
3323 goto err_free; 3323 goto err_free;
3324 } 3324 }
@@ -3365,25 +3365,27 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3365 dev->devno = nr; 3365 dev->devno = nr;
3366 dev->model = id->driver_info; 3366 dev->model = id->driver_info;
3367 dev->alt = -1; 3367 dev->alt = -1;
3368 dev->is_audio_only = has_audio && !(has_video || has_dvb); 3368 dev->is_audio_only = has_vendor_audio && !(has_video || has_dvb);
3369 dev->has_alsa_audio = has_audio;
3370 dev->has_video = has_video; 3369 dev->has_video = has_video;
3371 dev->ifnum = ifnum; 3370 dev->ifnum = ifnum;
3372 3371
3373 /* Checks if audio is provided by some interface */ 3372 if (has_vendor_audio) {
3373 printk(KERN_INFO DRIVER_NAME ": Audio interface %i found %s\n",
3374 ifnum, "(Vendor Class)");
3375 dev->usb_audio_type = EM28XX_USB_AUDIO_VENDOR;
3376 }
3377 /* Checks if audio is provided by a USB Audio Class interface */
3374 for (i = 0; i < udev->config->desc.bNumInterfaces; i++) { 3378 for (i = 0; i < udev->config->desc.bNumInterfaces; i++) {
3375 struct usb_interface *uif = udev->config->interface[i]; 3379 struct usb_interface *uif = udev->config->interface[i];
3376 if (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) { 3380 if (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
3377 dev->has_audio_class = 1; 3381 if (has_vendor_audio)
3382 em28xx_err("em28xx: device seems to have vendor AND usb audio class interfaces !\n"
3383 "\t\tThe vendor interface will be ignored. Please contact the developers <linux-media@vger.kernel.org>\n");
3384 dev->usb_audio_type = EM28XX_USB_AUDIO_CLASS;
3378 break; 3385 break;
3379 } 3386 }
3380 } 3387 }
3381 3388
3382 if (has_audio)
3383 printk(KERN_INFO DRIVER_NAME
3384 ": Audio interface %i found %s\n",
3385 ifnum,
3386 dev->has_audio_class ? "(USB Audio Class)" : "(Vendor Class)");
3387 if (has_video) 3389 if (has_video)
3388 printk(KERN_INFO DRIVER_NAME 3390 printk(KERN_INFO DRIVER_NAME
3389 ": Video interface %i found:%s%s\n", 3391 ": Video interface %i found:%s%s\n",
diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c
index 3bbab0e468de..147d73d4f03a 100644
--- a/drivers/media/usb/em28xx/em28xx-core.c
+++ b/drivers/media/usb/em28xx/em28xx-core.c
@@ -513,8 +513,7 @@ int em28xx_audio_setup(struct em28xx *dev)
513 dev->chip_id == CHIP_ID_EM28178) { 513 dev->chip_id == CHIP_ID_EM28178) {
514 /* Digital only device - don't load any alsa module */ 514 /* Digital only device - don't load any alsa module */
515 dev->audio_mode.has_audio = false; 515 dev->audio_mode.has_audio = false;
516 dev->has_audio_class = false; 516 dev->usb_audio_type = EM28XX_USB_AUDIO_NONE;
517 dev->has_alsa_audio = false;
518 return 0; 517 return 0;
519 } 518 }
520 519
@@ -528,8 +527,8 @@ int em28xx_audio_setup(struct em28xx *dev)
528 cfg = EM28XX_CHIPCFG_AC97; /* Be conservative */ 527 cfg = EM28XX_CHIPCFG_AC97; /* Be conservative */
529 } else if ((cfg & EM28XX_CHIPCFG_AUDIOMASK) == 0x00) { 528 } else if ((cfg & EM28XX_CHIPCFG_AUDIOMASK) == 0x00) {
530 /* The device doesn't have vendor audio at all */ 529 /* The device doesn't have vendor audio at all */
531 dev->has_alsa_audio = false;
532 dev->audio_mode.has_audio = false; 530 dev->audio_mode.has_audio = false;
531 dev->usb_audio_type = EM28XX_USB_AUDIO_NONE;
533 return 0; 532 return 0;
534 } else if ((cfg & EM28XX_CHIPCFG_AUDIOMASK) != EM28XX_CHIPCFG_AC97) { 533 } else if ((cfg & EM28XX_CHIPCFG_AUDIOMASK) != EM28XX_CHIPCFG_AC97) {
535 if (dev->chip_id < CHIP_ID_EM2860 && 534 if (dev->chip_id < CHIP_ID_EM2860 &&
@@ -560,7 +559,8 @@ int em28xx_audio_setup(struct em28xx *dev)
560 */ 559 */
561 em28xx_warn("AC97 chip type couldn't be determined\n"); 560 em28xx_warn("AC97 chip type couldn't be determined\n");
562 dev->audio_mode.ac97 = EM28XX_NO_AC97; 561 dev->audio_mode.ac97 = EM28XX_NO_AC97;
563 dev->has_alsa_audio = false; 562 if (dev->usb_audio_type == EM28XX_USB_AUDIO_VENDOR)
563 dev->usb_audio_type = EM28XX_USB_AUDIO_NONE;
564 dev->audio_mode.has_audio = false; 564 dev->audio_mode.has_audio = false;
565 goto init_audio; 565 goto init_audio;
566 } 566 }
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index 1f38163352b6..3fd176f99a23 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -312,6 +312,12 @@ struct em28xx_audio_mode {
312 unsigned int has_audio:1; 312 unsigned int has_audio:1;
313}; 313};
314 314
315enum em28xx_usb_audio_type {
316 EM28XX_USB_AUDIO_NONE = 0,
317 EM28XX_USB_AUDIO_CLASS,
318 EM28XX_USB_AUDIO_VENDOR,
319};
320
315/* em28xx has two audio inputs: tuner and line in. 321/* em28xx has two audio inputs: tuner and line in.
316 However, on most devices, an auxiliary AC97 codec device is used. 322 However, on most devices, an auxiliary AC97 codec device is used.
317 The AC97 device may have several different inputs and outputs, 323 The AC97 device may have several different inputs and outputs,
@@ -601,9 +607,8 @@ struct em28xx {
601 unsigned int is_em25xx:1; /* em25xx/em276x/7x/8x family bridge */ 607 unsigned int is_em25xx:1; /* em25xx/em276x/7x/8x family bridge */
602 unsigned char disconnected:1; /* device has been diconnected */ 608 unsigned char disconnected:1; /* device has been diconnected */
603 unsigned int has_video:1; 609 unsigned int has_video:1;
604 unsigned int has_audio_class:1;
605 unsigned int has_alsa_audio:1;
606 unsigned int is_audio_only:1; 610 unsigned int is_audio_only:1;
611 enum em28xx_usb_audio_type usb_audio_type;
607 612
608 struct em28xx_board board; 613 struct em28xx_board board;
609 614