V4L/DVB (11070): au0828: Rework the way the analog video binding occurs

Rework the way boards are managed so that we can change the board description
based on the Hauppauge eeprom (modeled after cx88-cards.c).

Also, make sure that we don't load the analog stack if there are no analog
inputs defined in the board profile.

Thanks to Michael Krufky <mkrufky@linuxtv.org> for providing information on
the various ways different Hauppauge boards can be configured.

Signed-off-by: Devin Heitmueller <dheitmueller@linuxtv.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/media/video/au0828/au0828-video.c b/drivers/media/video/au0828/au0828-video.c
index e34464f..064de23 100644
--- a/drivers/media/video/au0828/au0828-video.c
+++ b/drivers/media/video/au0828/au0828-video.c
@@ -1013,7 +1013,7 @@
 
 	memset(cap, 0, sizeof(*cap));
 	strlcpy(cap->driver, "au0828", sizeof(cap->driver));
-	strlcpy(cap->card, au0828_boards[dev->board].name, sizeof(cap->card));
+	strlcpy(cap->card, dev->board.name, sizeof(cap->card));
 	strlcpy(cap->bus_info, dev->usbdev->dev.bus_id, sizeof(cap->bus_info));
 
 	cap->version = AU0828_VERSION_CODE;
@@ -1127,14 +1127,14 @@
 
 	if(tmp > AU0828_MAX_INPUT)
 		return -EINVAL;
-	if(AUVI_INPUT(tmp)->type == 0)
+	if(AUVI_INPUT(tmp).type == 0)
 		return -EINVAL;
 
 	memset(input, 0, sizeof(*input));
 	input->index = tmp;
-	strcpy(input->name, inames[AUVI_INPUT(tmp)->type]);
-	if((AUVI_INPUT(tmp)->type == AU0828_VMUX_TELEVISION) ||
-	   (AUVI_INPUT(tmp)->type == AU0828_VMUX_CABLE))
+	strcpy(input->name, inames[AUVI_INPUT(tmp).type]);
+	if((AUVI_INPUT(tmp).type == AU0828_VMUX_TELEVISION) ||
+	   (AUVI_INPUT(tmp).type == AU0828_VMUX_CABLE))
 		input->type |= V4L2_INPUT_TYPE_TUNER;
 	else
 		input->type |= V4L2_INPUT_TYPE_CAMERA;
@@ -1163,11 +1163,11 @@
 		index);
 	if(index >= AU0828_MAX_INPUT)
 		return -EINVAL;
-	if(AUVI_INPUT(index)->type == 0)
+	if(AUVI_INPUT(index).type == 0)
 		return -EINVAL;
 	dev->ctrl_input = index;
 
-	switch(AUVI_INPUT(index)->type) {
+	switch(AUVI_INPUT(index).type) {
 	case AU0828_VMUX_SVIDEO:
 	{
 		dev->input_type = AU0828_VMUX_SVIDEO;
@@ -1187,13 +1187,13 @@
 		;
 	}
 
-	route.input = AUVI_INPUT(index)->vmux;
+	route.input = AUVI_INPUT(index).vmux;
 	route.output = 0;
 	au0828_call_i2c_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route);
 
 	for (i = 0; i < AU0828_MAX_INPUT; i++) {
 		int enable = 0;
-		if (AUVI_INPUT(i)->audio_setup == NULL) {
+		if (AUVI_INPUT(i).audio_setup == NULL) {
 			continue;
 		}
 
@@ -1202,18 +1202,18 @@
 		else
 			enable = 0;
 		if (enable) {
-			(AUVI_INPUT(i)->audio_setup)(dev, enable);
+			(AUVI_INPUT(i).audio_setup)(dev, enable);
 		} else {
 			/* Make sure we leave it turned on if some
 			   other input is routed to this callback */
-			if ((AUVI_INPUT(i)->audio_setup) !=
-			    ((AUVI_INPUT(index)->audio_setup))) {
-				(AUVI_INPUT(i)->audio_setup)(dev, enable);
+			if ((AUVI_INPUT(i).audio_setup) !=
+			    ((AUVI_INPUT(index).audio_setup))) {
+				(AUVI_INPUT(i).audio_setup)(dev, enable);
 			}
 		}
 	}
 
-	route.input = AUVI_INPUT(index)->amux;
+	route.input = AUVI_INPUT(index).amux;
 	au0828_call_i2c_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING,
 				&route);
 	return 0;
@@ -1419,10 +1419,10 @@
 	}
 
 	for (i = 0; i < AU0828_MAX_INPUT; i++) {
-		if (AUVI_INPUT(i)->audio_setup == NULL) {
+		if (AUVI_INPUT(i).audio_setup == NULL) {
 			continue;
 		}
-		(AUVI_INPUT(i)->audio_setup)(dev, 0);
+		(AUVI_INPUT(i).audio_setup)(dev, 0);
 	}
 
 	mutex_lock(&dev->lock);
@@ -1603,14 +1603,6 @@
 
 	dprintk(1, "au0828_analog_register called!\n");
 
-	/* Load the analog demodulator driver (note this would need to be
-	   abstracted out if we ever need to support a different demod) */
-	request_module("au8522");
-
-	/* Load the tuner module, which results in i2c enumeration and
-	   attachment of whatever tuner is on the bus */
-	request_module("tuner");
-
 	init_waitqueue_head(&dev->open);
 	spin_lock_init(&dev->slock);
 	mutex_init(&dev->lock);