Skip to contentSkip to conversation

add a "private" field to the ac97 struct

RFC In review Sebastian Siewior 3 participants 4 messages Mar 6, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 add a "private" field to the ac97 struct

I have a PowerPC board with an AC97 controller and that one has an UCB1400 attached.
Currently the UCB1400 driver discovers the interrupt via probing. This doesn't really work here. The resources are read from the device tree. I haven't found any other driver besides ucb1400_ts that uses the ac97_bus_type so I can't check where others get their HW information from.

My proposal is to introduce a new field in struct snd_ac97 where the AC97 driver can leave the required HW info regarding the attached (in my case the interrupt for the ucb1400) before calling snd_card_register(). I attached just a single int field since I am not aware if multiple devices / resource are realistic / possible. In that case maybe a void * or struct platform_device would be a better choice.

---
 drivers/input/touchscreen/ucb1400_ts.c |   13 ++++++++-----
 include/sound/ac97_codec.h             |    2 ++
 2 files changed, 10 insertions(+), 5 deletions(-)
drivers/input/touchscreen/ucb1400_ts.c +8 -5
index 607f993..95d1fea 100644
@@ -492,11 +492,14 @@ static int ucb1400_ts_probe(struct device *dev)
 		goto err_free_devs;
 	}
 
-	error = ucb1400_detect_irq(ucb);
-	if (error) {
-		printk(KERN_ERR "UCB1400: IRQ probe failed\n");
-		goto err_free_devs;
-	}
+	if (!ucb->ac97->device_irq) {
+		error = ucb1400_detect_irq(ucb);
+		if (error) {
+			printk(KERN_ERR "UCB1400: IRQ probe failed\n");
+			goto err_free_devs;
+		}
+	} else
+		ucb->irq = ucb->ac97->device_irq;
 
 	error = request_irq(ucb->irq, ucb1400_hard_irq, IRQF_TRIGGER_RISING,
 				"UCB1400", ucb);
include/sound/ac97_codec.h +2 -0
index 0148058..bf920a2 100644
@@ -474,6 +474,8 @@ struct snd_ac97 {
 	struct snd_ac97_build_ops * build_ops;
 	void *private_data;
 	void (*private_free) (struct snd_ac97 *ac97);
+	/* device attached to the AC97 bus */
+	int device_irq;
 	/* --- */
 	struct snd_ac97_bus *bus;
 	struct pci_dev *pci;	/* assigned PCI device - used for quirks */
Signature · 1 line
1.5.3.5
#1 lore raw

Hi,

Why not modify ucb1400_detect_irq() to get an openfirmware handle on PowerPC and read the resource tree at that time? This seems like a better approach.

William

Quoted 50 lines · Sebastian Siewior

I have a PowerPC board with an AC97 controller and that one has an UCB1400 attached.
Currently the UCB1400 driver discovers the interrupt via probing. This doesn't really work here. The resources are read from the device tree. I haven't found any other driver besides ucb1400_ts that uses the ac97_bus_type so I can't check where others get their HW information from.

My proposal is to introduce a new field in struct snd_ac97 where the AC97 driver can leave the required HW info regarding the attached (in my case the interrupt for the ucb1400) before calling snd_card_register(). I attached just a single int field since I am not aware if multiple devices / resource are realistic / possible. In that case maybe a void * or struct platform_device would be a better choice.

---
 drivers/input/touchscreen/ucb1400_ts.c |   13 ++++++++-----
 include/sound/ac97_codec.h             |    2 ++
 2 files changed, 10 insertions(+), 5 deletions(-)
drivers/input/touchscreen/ucb1400_ts.c +8 -5
index 607f993..95d1fea 100644
@@ -492,11 +492,14 @@ static int ucb1400_ts_probe(struct device *dev)
 		goto err_free_devs;
 	}
 
-	error = ucb1400_detect_irq(ucb);
-	if (error) {
-		printk(KERN_ERR "UCB1400: IRQ probe failed\n");
-		goto err_free_devs;
-	}
+	if (!ucb->ac97->device_irq) {
+		error = ucb1400_detect_irq(ucb);
+		if (error) {
+			printk(KERN_ERR "UCB1400: IRQ probe failed\n");
+			goto err_free_devs;
+		}
+	} else
+		ucb->irq = ucb->ac97->device_irq;
 
 	error = request_irq(ucb->irq, ucb1400_hard_irq, IRQF_TRIGGER_RISING,
 				"UCB1400", ucb);
include/sound/ac97_codec.h +0 -0
index 0148058..bf920a2 100644

include/sound/ac97_codec.h struct snd_ac97 { · line 481

Quoted 8 lines
include/sound/ac97_codec.h +2 -0
@@ -474,6 +474,8 @@ struct snd_ac97 {
 	struct snd_ac97_build_ops * build_ops;
 	void *private_data;
 	void (*private_free) (struct snd_ac97 *ac97);
+	/* device attached to the AC97 bus */
+	int device_irq;
 	/* --- */
 	struct snd_ac97_bus *bus;
 	struct pci_dev *pci;	/* assigned PCI device - used for quirks */

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#2 lore raw
Quoted 1 line · * William Pitcock | 2008-03-06 11:12:37 [-0600]:

Hi,

Hi,

Quoted 3 lines

Why not modify ucb1400_detect_irq() to get an openfirmware handle on PowerPC and read the resource tree at that time? This seems like a better approach.

That was my first approach:

---
 drivers/input/touchscreen/Kconfig      |    7 ++++
 drivers/input/touchscreen/ucb1400_ts.c |   57 +++++++++++++++++++++++++++++++-
 2 files changed, 63 insertions(+), 1 deletions(-)
drivers/input/touchscreen/Kconfig +7 -0
index 90e8e92..8f4d752 100644
@@ -185,6 +185,13 @@ config TOUCHSCREEN_UCB1400
 	  To compile this driver as a module, choose M here: the
 	  module will be called ucb1400_ts.
 
+config TOUCHSCREEN_UCB1400_OF
+	bool "Get device informations via the device tree"
+	depends on TOUCHSCREEN_UCB1400 && OF
+	help
+	  Select this option if you want to obtain interrupt information from
+	  the device tree instead of auto probing.
+
 config TOUCHSCREEN_USB_COMPOSITE
 	tristate "USB Touchscreen Driver"
 	depends on USB_ARCH_HAS_HCD
drivers/input/touchscreen/ucb1400_ts.c +56 -1

100 lines not on this page · raw message

Signature · 5 lines
1.5.3.5

The problem is more or less that I can't pass the value to the other
probe function and the global variable doesn't look all that pretty. Am
I missing something here?
Quoted 1 line

William

Sebastian

#3 lore raw
Quoted 3 lines · Sebastian Siewior

The problem is more or less that I can't pass the value to the other probe function and the global variable doesn't look all that pretty. Am I missing something here?

This is also a problem for the wm97xx touchscreen drivers. They have a similar issue with wanting to get platform configuration into a device probed off the AC97 bus with the additional issue that features like syncing with screen redraw will often require code to interface with other hardware in the system. If something is added to the AC97 data it'd be helpful if it were a void * so the wm97xx touch driver could use it to pass a struct with more data.

This is not really an AC97-specific issue - any device discoverd via a bus is going to have a similar thing if it needs to obtain platform data. I don't know how OpenFirmware normally handles these things? It's going to be an issue for other buses like PCI too in many systems, MAC addresses for NICs being the example I've run into myself in a previous life.

In the case of the wm97xx touchscreen we've avoided the problem by having the touch driver register platform devices; this isn't ideal but works well in the systems which are the typical targets for these devices. I had been intending to revisit this issue at some point but it's quite a way down my TODO list.

The wm97xx drivers touch aren't in mainline yet - if you want to have a look the most current upstream submission versions can be found in the upstream branch of:

git://opensource.wolfsonmicro.com/linux-2.6-touch

gitweb:

http://opensource.wolfsonmicro.com/cgi-bin/gitweb.cgi?p=linux-2.6-touch.git;a=summary