linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: unlisted-recipients:; (no To-header on input)@canuck.infradead.org
Cc: Antti Palosaari <crope@iki.fi>, Kay Sievers <kay@redhat.com>,
	Greg KH <gregkh@linuxfoundation.org>,
	Mauro Carvalho Chehab <mchehab@redhat.com>,
	Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: [PATCH RFC 2/4] em28xx: defer probe() if userspace mode is disabled
Date: Tue, 26 Jun 2012 16:34:20 -0300	[thread overview]
Message-ID: <1340739262-13747-3-git-send-email-mchehab@redhat.com> (raw)
In-Reply-To: <1340739262-13747-1-git-send-email-mchehab@redhat.com>

Some em28xx devices with tuner-xc2028, drx-k and drx-d need firmware, in
order to be probed. Defer device probe on those devices, if userspace mode is
disabled.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/video/em28xx/em28xx-cards.c |   42 +++++++++++++++++++++++++++++
 drivers/media/video/em28xx/em28xx.h       |    1 +
 2 files changed, 43 insertions(+)

diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 12bc54a..9229cd2 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -776,6 +776,7 @@ struct em28xx_board em28xx_boards[] = {
 		.name         = "Terratec Cinergy A Hybrid XS",
 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.decoder      = EM28XX_TVP5150,
 
@@ -800,6 +801,7 @@ struct em28xx_board em28xx_boards[] = {
 		.name	      = "KWorld PVRTV 300U",
 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.decoder      = EM28XX_TVP5150,
 		.input        = { {
@@ -880,6 +882,7 @@ struct em28xx_board em28xx_boards[] = {
 		.name         = "Terratec Cinergy T XS",
 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 	},
 	[EM2870_BOARD_TERRATEC_XS_MT2060] = {
@@ -891,6 +894,7 @@ struct em28xx_board em28xx_boards[] = {
 		.name         = "Kworld 350 U DVB-T",
 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 	},
 	[EM2870_BOARD_KWORLD_355U] = {
@@ -919,6 +923,7 @@ struct em28xx_board em28xx_boards[] = {
 		.name         = "Terratec Hybrid XS Secam",
 		.has_msp34xx  = 1,
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.decoder      = EM28XX_TVP5150,
 		.has_dvb      = 1,
@@ -970,6 +975,7 @@ struct em28xx_board em28xx_boards[] = {
 		.i2c_speed    = EM2874_I2C_SECONDARY_BUS_SELECT |
 				EM28XX_I2C_CLK_WAIT_ENABLE |
 				EM28XX_I2C_FREQ_400_KHZ,
+		.needs_firmware = true,
 	},
 	[EM2884_BOARD_CINERGY_HTC_STICK] = {
 		.name         = "Terratec Cinergy HTC Stick",
@@ -979,11 +985,13 @@ struct em28xx_board em28xx_boards[] = {
 		.i2c_speed    = EM2874_I2C_SECONDARY_BUS_SELECT |
 				EM28XX_I2C_CLK_WAIT_ENABLE |
 				EM28XX_I2C_FREQ_400_KHZ,
+		.needs_firmware = true,
 	},
 	[EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
 		.name         = "Hauppauge WinTV HVR 900",
 		.tda9887_conf = TDA9887_PRESENT,
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.mts_firmware = 1,
 		.has_dvb      = 1,
@@ -1011,6 +1019,7 @@ struct em28xx_board em28xx_boards[] = {
 		.name         = "Hauppauge WinTV HVR 900 (R2)",
 		.tda9887_conf = TDA9887_PRESENT,
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.mts_firmware = 1,
 		.has_dvb      = 1,
@@ -1037,6 +1046,7 @@ struct em28xx_board em28xx_boards[] = {
 	[EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850] = {
 		.name           = "Hauppauge WinTV HVR 850",
 		.tuner_type     = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio     = default_tuner_gpio,
 		.mts_firmware   = 1,
 		.has_dvb        = 1,
@@ -1063,6 +1073,7 @@ struct em28xx_board em28xx_boards[] = {
 	[EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950] = {
 		.name           = "Hauppauge WinTV HVR 950",
 		.tuner_type     = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio     = default_tuner_gpio,
 		.mts_firmware   = 1,
 		.has_dvb        = 1,
@@ -1089,6 +1100,7 @@ struct em28xx_board em28xx_boards[] = {
 	[EM2880_BOARD_PINNACLE_PCTV_HD_PRO] = {
 		.name           = "Pinnacle PCTV HD Pro Stick",
 		.tuner_type     = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.mts_firmware   = 1,
 		.has_dvb        = 1,
@@ -1115,6 +1127,7 @@ struct em28xx_board em28xx_boards[] = {
 	[EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600] = {
 		.name           = "AMD ATI TV Wonder HD 600",
 		.tuner_type     = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio     = default_tuner_gpio,
 		.mts_firmware   = 1,
 		.has_dvb        = 1,
@@ -1141,6 +1154,7 @@ struct em28xx_board em28xx_boards[] = {
 	[EM2880_BOARD_TERRATEC_HYBRID_XS] = {
 		.name           = "Terratec Hybrid XS",
 		.tuner_type     = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio     = default_tuner_gpio,
 		.decoder        = EM28XX_TVP5150,
 		.has_dvb        = 1,
@@ -1170,6 +1184,7 @@ struct em28xx_board em28xx_boards[] = {
 	[EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
 		.name         = "Terratec Prodigy XS",
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.decoder      = EM28XX_TVP5150,
 		.input        = { {
@@ -1412,6 +1427,7 @@ struct em28xx_board em28xx_boards[] = {
 		.name         = "MSI DigiVox A/D",
 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.decoder      = EM28XX_TVP5150,
 		.input        = { {
@@ -1435,6 +1451,7 @@ struct em28xx_board em28xx_boards[] = {
 		.name         = "MSI DigiVox A/D II",
 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.decoder      = EM28XX_TVP5150,
 		.input        = { {
@@ -1457,6 +1474,7 @@ struct em28xx_board em28xx_boards[] = {
 	[EM2880_BOARD_KWORLD_DVB_305U] = {
 		.name	      = "KWorld DVB-T 305U",
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.decoder      = EM28XX_TVP5150,
 		.input        = { {
@@ -1476,6 +1494,7 @@ struct em28xx_board em28xx_boards[] = {
 	[EM2880_BOARD_KWORLD_DVB_310U] = {
 		.name	      = "KWorld DVB-T 310U",
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.has_dvb      = 1,
 		.dvb_gpio     = default_digital,
@@ -1534,6 +1553,7 @@ struct em28xx_board em28xx_boards[] = {
 	[EM2880_BOARD_EMPIRE_DUAL_TV] = {
 		.name = "Empire dual TV",
 		.tuner_type = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio = default_tuner_gpio,
 		.has_dvb = 1,
 		.dvb_gpio = default_digital,
@@ -1560,6 +1580,7 @@ struct em28xx_board em28xx_boards[] = {
 		.name         = "DNT DA2 Hybrid",
 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.decoder      = EM28XX_TVP5150,
 		.input        = { {
@@ -1582,6 +1603,7 @@ struct em28xx_board em28xx_boards[] = {
 	[EM2881_BOARD_PINNACLE_HYBRID_PRO] = {
 		.name         = "Pinnacle Hybrid Pro",
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.decoder      = EM28XX_TVP5150,
 		.has_dvb      = 1,
@@ -1606,6 +1628,7 @@ struct em28xx_board em28xx_boards[] = {
 	[EM2882_BOARD_PINNACLE_HYBRID_PRO_330E] = {
 		.name         = "Pinnacle Hybrid Pro (330e)",
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.mts_firmware = 1,
 		.has_dvb      = 1,
@@ -1632,6 +1655,7 @@ struct em28xx_board em28xx_boards[] = {
 	[EM2882_BOARD_KWORLD_VS_DVBT] = {
 		.name         = "Kworld VS-DVB-T 323UR",
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.decoder      = EM28XX_TVP5150,
 		.mts_firmware = 1,
@@ -1656,6 +1680,7 @@ struct em28xx_board em28xx_boards[] = {
 	[EM2882_BOARD_TERRATEC_HYBRID_XS] = {
 		.name         = "Terratec Cinnergy Hybrid T USB XS (em2882)",
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.mts_firmware = 1,
 		.decoder      = EM28XX_TVP5150,
@@ -1683,6 +1708,7 @@ struct em28xx_board em28xx_boards[] = {
 	[EM2882_BOARD_DIKOM_DK300] = {
 		.name         = "Dikom DK300",
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.decoder      = EM28XX_TVP5150,
 		.mts_firmware = 1,
@@ -1698,6 +1724,7 @@ struct em28xx_board em28xx_boards[] = {
 	[EM2883_BOARD_KWORLD_HYBRID_330U] = {
 		.name         = "Kworld PlusTV HD Hybrid 330",
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.decoder      = EM28XX_TVP5150,
 		.mts_firmware = 1,
@@ -1750,6 +1777,7 @@ struct em28xx_board em28xx_boards[] = {
 		.name	      = "Kaiomy TVnPC U2",
 		.vchannels    = 3,
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_addr   = 0x61,
 		.mts_firmware = 1,
 		.decoder      = EM28XX_TVP5150,
@@ -1864,6 +1892,7 @@ struct em28xx_board em28xx_boards[] = {
 	[EM2882_BOARD_EVGA_INDTUBE] = {
 		.name         = "Evga inDtube",
 		.tuner_type   = TUNER_XC2028,
+		.needs_firmware = true,
 		.tuner_gpio   = default_tuner_gpio,
 		.decoder      = EM28XX_TVP5150,
 		.xclk         = EM28XX_XCLK_FREQUENCY_12MHZ, /* NEC IR */
@@ -3133,6 +3162,19 @@ static int em28xx_usb_probe(struct usb_interface *interface,
 	const int ifnum = interface->altsetting[0].desc.bInterfaceNumber;
 	char *speed;
 
+	/*
+	 * If the device requires firmware, probe() may need to be
+	 * postponed, as udev may not be ready yet to honour firmware
+	 * load requests.
+	 */
+	if (em28xx_boards[id->driver_info].needs_firmware &&
+	    is_usermodehelp_disabled()) {
+		printk_once(KERN_DEBUG DRIVER_NAME
+		            ": probe deferred for board %d.\n",
+		            (unsigned)id->driver_info);
+		return -EPROBE_DEFER;
+	}
+
 	udev = usb_get_dev(interface_to_usbdev(interface));
 
 	/* Check to see next free device and mark as used */
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index 8757523..ed8dc65 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -402,6 +402,7 @@ struct em28xx_board {
 	unsigned int is_webcam:1;
 	unsigned int valid:1;
 	unsigned int has_ir_i2c:1;
+	unsigned int needs_firmware:1;
 
 	unsigned char xclk, i2c_speed;
 	unsigned char radio_addr;
-- 
1.7.10.2


  parent reply	other threads:[~2012-06-26 19:34 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-21 13:36 [PATCH] [media] drxk: change it to use request_firmware_nowait() Mauro Carvalho Chehab
2012-06-21 14:21 ` Devin Heitmueller
2012-06-21 15:09   ` Mauro Carvalho Chehab
2012-06-21 19:10 ` Mauro Carvalho Chehab
2012-06-22 14:11   ` Marko Ristola
2012-06-25 19:15   ` Antti Palosaari
2012-06-25 20:06     ` Mauro Carvalho Chehab
2012-06-25 20:47       ` Need of an ".async_probe()" type of callback at driver's core - Was: " Mauro Carvalho Chehab
2012-06-25 20:49       ` Mauro Carvalho Chehab
2012-06-25 22:33         ` Greg KH
2012-06-26  1:55           ` Mauro Carvalho Chehab
2012-06-26 19:34             ` [PATCH RFC 0/4] Defer probe() on em28xx when firmware load is required Mauro Carvalho Chehab
2012-06-26 19:34               ` [PATCH RFC 1/4] kmod: add a routine to return if usermode is disabled Mauro Carvalho Chehab
2012-06-26 20:38                 ` Greg KH
2012-06-26 21:05                   ` Mauro Carvalho Chehab
2012-06-26 19:34               ` Mauro Carvalho Chehab [this message]
2012-06-26 20:43                 ` [PATCH RFC 2/4] em28xx: defer probe() if userspace mode " Greg KH
2012-06-26 21:30                   ` Mauro Carvalho Chehab
2012-06-26 19:34               ` [PATCH RFC 3/4] em28xx: Workaround for new udev versions Mauro Carvalho Chehab
2012-06-26 20:40                 ` Greg KH
2012-06-26 21:07                   ` Mauro Carvalho Chehab
2012-06-26 21:56                     ` Kay Sievers
2012-06-26 20:42                 ` Greg KH
2012-06-26 21:21                   ` Mauro Carvalho Chehab
2012-06-26 21:27                     ` Greg KH
2012-06-26 22:01                       ` Mauro Carvalho Chehab
2012-06-28 17:51                         ` Mauro Carvalho Chehab
2012-06-26 19:34               ` [PATCH RFC 4/4] tuner-xc2028: tag the usual firmwares to help dracut Mauro Carvalho Chehab
2012-06-26 20:44                 ` Greg KH
2012-06-26 21:34                   ` Mauro Carvalho Chehab
2012-10-02 13:03             ` udev breakages - was: Re: Need of an ".async_probe()" type of callback at driver's core - Was: Re: [PATCH] [media] drxk: change it to use request_firmware_nowait() Mauro Carvalho Chehab
2012-10-02 16:33               ` Linus Torvalds
2012-10-02 21:03                 ` Ivan Kalvachev
2012-10-02 22:37                   ` Linus Torvalds
2012-10-03 22:15                     ` Lucas De Marchi
2012-10-02 22:12                 ` Greg KH
2012-10-02 22:23                   ` Greg KH
2012-10-02 22:47                     ` Linus Torvalds
2012-10-03  0:01                       ` Jiri Kosina
2012-10-03  0:12                         ` Linus Torvalds
2012-10-04 14:36                           ` Jiri Kosina
2012-10-03 15:13                       ` Mauro Carvalho Chehab
2012-10-03 16:38                         ` Linus Torvalds
2012-10-03 17:00                           ` Linus Torvalds
2012-10-03 17:09                           ` Al Viro
2012-10-03 17:32                             ` Linus Torvalds
2012-10-03 19:26                               ` Al Viro
2012-10-04  0:57                                 ` udev breakages - Nix
2012-10-04 10:35                                   ` Nix
2012-10-03 19:50                               ` udev breakages - was: Re: Need of an ".async_probe()" type of callback at driver's core - Was: Re: [PATCH] [media] drxk: change it to use request_firmware_nowait() Greg KH
2012-10-03 20:39                                 ` Linus Torvalds
2012-10-03 21:04                                   ` Kay Sievers
2012-10-03 21:05                                   ` Greg KH
2012-10-03 21:18                                     ` Kay Sievers
2012-10-03 21:45                                       ` Alan Cox
2012-10-03 21:58                                   ` Lucas De Marchi
2012-10-03 22:17                                     ` Linus Torvalds
2012-10-03 22:48                                   ` Andy Walls
2012-10-03 22:58                                     ` Linus Torvalds
2012-10-04  2:39                                       ` Kay Sievers
2012-10-04 17:29                                         ` udev breakages - Eric W. Biederman
2012-10-04 17:42                                           ` Greg KH
2012-10-04 19:17                                             ` Alan Cox
2012-10-10  3:19                                               ` Felipe Contreras
2012-10-10 16:08                                                 ` Geert Uytterhoeven
2012-10-11  3:32                                             ` Eric W. Biederman
2012-10-04 13:39                                       ` udev breakages - was: Re: Need of an ".async_probe()" type of callback at driver's core - Was: Re: [PATCH] [media] drxk: change it to use request_firmware_nowait() Josh Boyer
2012-10-04 13:58                                         ` Greg KH
2012-10-03 22:53                                   ` Stephen Rothwell
2012-10-03 21:10                                 ` Andy Walls
2012-10-03 19:48                           ` Access files from kernel Kirill A. Shutemov
2012-10-03 20:32                             ` Linus Torvalds
     [not found]                           ` <CACVXFVNTZmG+zTQNi9mCn9ynsCjkM084TmHKDcYYggtqLfhqNQ@mail.gmail.com>
2012-10-04  1:42                             ` udev breakages - was: Re: Need of an ".async_probe()" type of callback at driver's core - Was: Re: [PATCH] [media] drxk: change it to use request_firmware_nowait() Linus Torvalds
2012-10-03 14:12                     ` Mauro Carvalho Chehab
2012-10-03 14:36                   ` Kay Sievers
2012-10-03 14:44                     ` Linus Torvalds
2012-10-03 16:57                     ` Greg KH
2012-10-03 17:24                       ` Kay Sievers
2012-10-03 18:07                         ` Linus Torvalds
2012-10-03 19:46                       ` Mauro Carvalho Chehab
2012-06-29  8:26       ` Jean Delvare

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1340739262-13747-3-git-send-email-mchehab@redhat.com \
    --to=mchehab@redhat.com \
    --cc=crope@iki.fi \
    --cc=gregkh@linuxfoundation.org \
    --cc=kay@redhat.com \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).