Skip to contentSkip to conversation

snd-aoa: add snd-aoa

RFC In review Johannes Berg 3 participants 38 messages Jun 1, 2006 – Jun 7, 2006

Subsystems (2)
lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

cover snd-aoa: add snd-aoa

The following patches would add snd-aoa to the Linux source tree. I'm posting them here in the spirit of getting review fairly early, it works fine for those machines it handles and even implements headphone/line-out detection now.

One thing that still needs to be done is fix this on the mac-mini where apparently some things are missing from the device-tree, and on the PowerMac7,2/7,3 where the device tree has a bug that prevents the i2sbus module from working properly.

Other than that, it replaces snd-powermac for all layout-id machines, and handles many more already, so once those two issues are fixed I'll also add a patch to this patchset that removes support for any machines with a layout-id from snd-powermac to allow snd-aoa and snd-powermac to coexist nicely.

Any comments are appreciated.

--

author maintainer
#1 lore raw

RFC 1/8 snd-aoa: add aoa header files

This patch adds header files to use for communication between the various parts of aoa.

sound/aoa/aoa-gpio.h new file +81 -0
@@ -0,0 +1,81 @@
+/*
+ * Apple Onboard Audio GPIO definitions
+ *
+ * Copyright 2006 Johannes Berg <[email protected]>
+ *
+ * GPL v2, can be found in COPYING.
+ */
+
+#ifndef __AOA_GPIO_H
+#define __AOA_GPIO_H
+#include <linux/workqueue.h>
+#include <linux/mutex.h>
+#include <asm/prom.h>
+
+typedef void (*notify_func_t)(void *data);
+
+enum notify_type {
+	AOA_NOTIFY_HEADPHONE,
+	AOA_NOTIFY_LINE_IN,
+	AOA_NOTIFY_LINE_OUT,
+};
+
+struct gpio_runtime;
+struct gpio_methods {
+	/* for initialisation/de-initialisation of the GPIO layer */
+	void (*init)(struct gpio_runtime *rt);
+	void (*exit)(struct gpio_runtime *rt);
+
+	/* turn off headphone, speakers, lineout */
+	void (*all_amps_off)(struct gpio_runtime *rt);
+	/* turn headphone, speakers, lineout back to previous setting */
+	void (*all_amps_restore)(struct gpio_runtime *rt);
+
+	void (*set_headphone)(struct gpio_runtime *rt, int on);
+	void (*set_speakers)(struct gpio_runtime *rt, int on);
+	void (*set_lineout)(struct gpio_runtime *rt, int on);
+
+	int (*get_headphone)(struct gpio_runtime *rt);
+	int (*get_speakers)(struct gpio_runtime *rt);
+	int (*get_lineout)(struct gpio_runtime *rt);
+
+	void (*set_hw_reset)(struct gpio_runtime *rt, int on);
+
+	/* use this to be notified of any events. The notification
+	 * function is passed the data, and is called in process
+	 * context by the use of schedule_work.
+	 * The interface for it is that setting a function to NULL
+	 * removes it, and they return 0 if the operation succeeded,
+	 * and -EBUSY if the notification is already assigned by
+	 * someone else. */
+	int (*set_notify)(struct gpio_runtime *rt,
+			  enum notify_type type,
+			  notify_func_t notify,
+			  void *data);
+	/* returns 0 if not plugged in, 1 if plugged in
+	 * or a negative error code */
+	int (*get_detect)(struct gpio_runtime *rt,
+			  enum notify_type type);
+};
+
+struct gpio_notification {
+	notify_func_t notify;
+	void *data;
+	void *gpio_private;
+	struct work_struct work;
+	struct mutex mutex;
+};
+
+struct gpio_runtime {
+	/* to be assigned by fabric */
+	struct device_node *node;
+	/* since everyone needs this pointer anyway... */
+	struct gpio_methods *methods;
+	/* to be used by the gpio implementation */
+	int implementation_private;
+	struct gpio_notification headphone_notify;
+	struct gpio_notification line_in_notify;
+	struct gpio_notification line_out_notify;
+};
+
+#endif /* __AOA_GPIO_H */
sound/aoa/aoa.h new file +130 -0

130 lines not on this page · raw message

--

author maintainer
#2 lore raw

RFC 2/8 snd-aoa: add aoa core

In reply to Johannes Berg

This patch adds the core of aoa, in itself pretty useless, but providing useful functions to other modules.

sound/aoa/core/Makefile new file +4 -0
@@ -0,0 +1,4 @@
+obj-$(CONFIG_SND_AOA) += snd-aoa.o
+snd-aoa-objs := snd-aoa-core.o \
+		snd-aoa-alsa.o \
+		snd-aoa-gpio-pmf.o
sound/aoa/core/snd-aoa-core.c new file +153 -0

153 lines not on this page · raw message

sound/aoa/core/snd-aoa-gpio-pmf.c new file +231 -0

231 lines not on this page · raw message

sound/aoa/core/snd-aoa-alsa.h new file +17 -0
@@ -0,0 +1,17 @@
+/*
+ * Apple Onboard Audio Alsa private helpers
+ *
+ * Copyright 2006 Johannes Berg <[email protected]>
+ *
+ * GPL v2, can be found in COPYING.
+ */
+
+#ifndef __SND_AOA_ALSA_H
+#define __SND_AOA_ALSA_H
+/* FIXME */
+#include "../aoa.h"
+
+extern int aoa_alsa_init(char *name, struct module *mod);
+extern void aoa_alsa_cleanup(void);
+
+#endif /* __SND_AOA_ALSA_H */
sound/aoa/core/snd-aoa-alsa.c new file +95 -0

95 lines not on this page · raw message

--

#3 lore raw

Re: [RFC 2/8] snd-aoa: add aoa core

At Thu, 01 Jun 2006 13:58:46 +0200,

Quoted 18 lines · Johannes Berg
sound/aoa/core/snd-aoa-core.c new file +14 -0
@@ -0,0 +1,153 @@
+/*
+ * Apple Onboard Audio driver core
+ *
+ * Copyright 2006 Johannes Berg <[email protected]>
+ *
+ * GPL v2, can be found in COPYING.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/list.h>
+#include "../aoa.h"
+#include "snd-aoa-alsa.h"
+

sound/aoa/core/snd-aoa-core.c line 24

Quoted 10 lines
sound/aoa/core/snd-aoa-core.c new file +10 -0
+MODULE_DESCRIPTION("Apple Onboard Audio Sound Driver");
+MODULE_AUTHOR("Johannes Berg <[email protected]>");
+MODULE_LICENSE("GPL");
+
+/* We allow only one fabric. This simplifies things,
+ * and more don't really make that much sense */
+static struct aoa_fabric *fabric;
+static LIST_HEAD(codec_list);
+
+static void attach_codec_to_fabric(struct aoa_codec *c)

Doesn't this need to return an error?
I'm afraid that module count is unblanced in the error path of aoa_corec_[un]register().

sound/aoa/core/snd-aoa-core.c line 36

Quoted 12 lines
sound/aoa/core/snd-aoa-core.c new file +12 -0
+{
+	int err;
+
+	if (!try_module_get(c->owner))
+		return;
+	/* found_codec has to be assigned */
+	err = -ENOENT;
+	if (fabric->found_codec)
+		err = fabric->found_codec(c);
+	if (err) {
+		module_put(c->owner);
+		printk("snd-aoa: fabric didn't like codec %s\n", c->name);

Add KERN_* prefix.

sound/aoa/core/snd-aoa-core.c line 45

Quoted 9 lines
sound/aoa/core/snd-aoa-core.c new file +9 -0
+		return;
+	}
+	c->fabric = fabric;
+
+	err = 0;
+	if (c->init)
+		err = c->init(c);
+	if (err) {
+		printk("snd-aoa: codec %s didn't init\n", c->name);

Ditto.

Quoted 2 lines
sound/aoa/core/snd-aoa-gpio-pmf.c new file +0 -0

(snip)

sound/aoa/core/snd-aoa-gpio-pmf.c line 80

Quoted 7 lines
sound/aoa/core/snd-aoa-gpio-pmf.c new file +7 -0
+static void pmf_gpio_init(struct gpio_runtime *rt)
+{
+	pmf_gpio_all_amps_off(rt);
+	rt->implementation_private = 0;
+	INIT_WORK(&rt->headphone_notify.work, pmf_handle_notify, &rt->headphone_notify);
+	INIT_WORK(&rt->line_in_notify.work, pmf_handle_notify, &rt->line_in_notify);
+	INIT_WORK(&rt->line_out_notify.work, pmf_handle_notify, &rt->line_out_notify);

Too long lines.

Quoted 5 lines
sound/aoa/core/snd-aoa-gpio-pmf.c new file +5 -0
+	mutex_init(&rt->headphone_notify.mutex);
+	mutex_init(&rt->line_in_notify.mutex);
+	mutex_init(&rt->line_out_notify.mutex);
+}
+

sound/aoa/core/snd-aoa-gpio-pmf.c line 95

Quoted 10 lines
sound/aoa/core/snd-aoa-gpio-pmf.c new file +10 -0
+static void pmf_gpio_exit(struct gpio_runtime *rt)
+{
+	pmf_gpio_all_amps_off(rt);
+	rt->implementation_private = 0;
+	if (rt->headphone_notify.gpio_private)
+		pmf_unregister_irq_client(rt->headphone_notify.gpio_private);
+	if (rt->line_in_notify.gpio_private)
+		pmf_unregister_irq_client(rt->line_in_notify.gpio_private);
+	if (rt->line_out_notify.gpio_private)
+		pmf_unregister_irq_client(rt->line_out_notify.gpio_private);

Don't need kfree(gpio_private)?

Quoted 2 lines
sound/aoa/core/snd-aoa-alsa.c new file +0 -0

(snip)

Quoted 8 lines
sound/aoa/core/snd-aoa-alsa.c new file +8 -0
+int aoa_alsa_init(char *name, struct module *mod)
+{
+	struct snd_card *alsa_card;
+	int err;
+
+	if (aoa_card)
+		/* cannot be EEXIST due to usage in aoa_fabric_register */
+		return -EBUSY;

sound/aoa/core/snd-aoa-alsa.c line 34

Quoted 10 lines
sound/aoa/core/snd-aoa-alsa.c new file +10 -0
+
+	alsa_card = snd_card_new(index, name, mod, sizeof(struct aoa_card));
+	if (!alsa_card)
+		return -ENOMEM;
+	aoa_card = alsa_card->private_data;
+	aoa_card->alsa_card = alsa_card;
+	strlcpy(alsa_card->driver, "AppleOnbdAudio", sizeof(alsa_card->driver)-1);
+	strlcpy(alsa_card->shortname, name, sizeof(alsa_card->shortname)-1);
+	strlcpy(alsa_card->longname, name, sizeof(alsa_card->longname)-1);
+	strlcpy(alsa_card->mixername, name, sizeof(alsa_card->mixername)-1);

Pass sizeof() without -1. strlcpy() takes the size of the buffer including nul-terminator.

Takashi

author maintainer
#4 lore raw

Re: [RFC 2/8] snd-aoa: add aoa core

Quoted 5 lines · Takashi Iwai
Quoted 1 line

+static void attach_codec_to_fabric(struct aoa_codec *c)

Doesn't this need to return an error?
I'm afraid that module count is unblanced in the error path of aoa_corec_[un]register().

Not sure, I'll have to take a look.

Quoted 3 lines

sound/aoa/core/snd-aoa-core.c line 36

Quoted 1 line
sound/aoa/core/snd-aoa-core.c new file +1 -0
+		printk("snd-aoa: fabric didn't like codec %s\n", c->name);

Add KERN_* prefix.

Uh, right.

Quoted 6 lines

sound/aoa/core/snd-aoa-gpio-pmf.c line 80

Quoted 4 lines
sound/aoa/core/snd-aoa-gpio-pmf.c new file +4 -0
+	rt->implementation_private = 0;
+	INIT_WORK(&rt->headphone_notify.work, pmf_handle_notify, &rt->headphone_notify);
+	INIT_WORK(&rt->line_in_notify.work, pmf_handle_notify, &rt->line_in_notify);
+	INIT_WORK(&rt->line_out_notify.work, pmf_handle_notify, &rt->line_out_notify);

Too long lines.

Heh, I knew I'd get this at lots of places, I'll work on it.

Quoted 10 lines

sound/aoa/core/snd-aoa-gpio-pmf.c line 95

Quoted 8 lines
sound/aoa/core/snd-aoa-gpio-pmf.c new file +8 -0
+	pmf_gpio_all_amps_off(rt);
+	rt->implementation_private = 0;
+	if (rt->headphone_notify.gpio_private)
+		pmf_unregister_irq_client(rt->headphone_notify.gpio_private);
+	if (rt->line_in_notify.gpio_private)
+		pmf_unregister_irq_client(rt->line_in_notify.gpio_private);
+	if (rt->line_out_notify.gpio_private)
+		pmf_unregister_irq_client(rt->line_out_notify.gpio_private);

Don't need kfree(gpio_private)?

Indeed, forgot that.

Quoted 7 lines

sound/aoa/core/snd-aoa-alsa.c line 34

Quoted 4 lines
sound/aoa/core/snd-aoa-alsa.c new file +4 -0
+	strlcpy(alsa_card->driver, "AppleOnbdAudio", sizeof(alsa_card->driver)-1);
+	strlcpy(alsa_card->shortname, name, sizeof(alsa_card->shortname)-1);
+	strlcpy(alsa_card->longname, name, sizeof(alsa_card->longname)-1);
+	strlcpy(alsa_card->mixername, name, sizeof(alsa_card->mixername)-1);

Pass sizeof() without -1. strlcpy() takes the size of the buffer including nul-terminator.

Yeah, I was confused about the API. Will fix those too.

Thanks,
johannes

_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

author maintainer
#5 lore raw

RFC 3/8 snd-aoa: add soundbus

In reply to Johannes Berg

This patch adds the mostly generic soundbus that will be used for all the sound busses Apple machines have and provides just the hooks for automatic driver loading etc.

sound/aoa/soundbus/Kconfig new file +14 -0
@@ -0,0 +1,14 @@
+config SND_AOA_SOUNDBUS
+	tristate "Apple Soundbus support"
+	depends on SOUND && SND_PCM && EXPERIMENTAL
+	---help---
+	This option enables the generic driver for the soundbus
+	support on Apple machines.
+	
+	It is required for the sound bus implementations.
+
+config SND_AOA_SOUNDBUS_I2S
+	tristate "I2S bus support"
+	depends on SND_AOA_SOUNDBUS && PCI
+	---help---
+	This option enables support for Apple I2S busses.
sound/aoa/soundbus/Makefile new file +3 -0
@@ -0,0 +1,3 @@
+obj-$(CONFIG_SND_AOA_SOUNDBUS) += snd-aoa-soundbus.o
+snd-aoa-soundbus-objs := core.o sysfs.o
+obj-$(CONFIG_SND_AOA_SOUNDBUS_I2S) += i2sbus/
sound/aoa/soundbus/soundbus.h new file +202 -0

202 lines not on this page · raw message

sound/aoa/soundbus/sysfs.c new file +67 -0

67 lines not on this page · raw message

sound/aoa/soundbus/core.c new file +250 -0

250 lines not on this page · raw message

--

#6 lore raw

Re: [RFC 3/8] snd-aoa: add soundbus

At Thu, 01 Jun 2006 13:58:47 +0200,

Quoted 11 lines · Johannes Berg
sound/aoa/soundbus/sysfs.c new file +8 -0
+static ssize_t
+compatible_show (struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct of_device *of;
+	char *compat;
+	int cplen;
+	int length = 0;
+

sound/aoa/soundbus/sysfs.c line 33

Quoted 10 lines
sound/aoa/soundbus/sysfs.c new file +10 -0
+	of = &to_soundbus_device (dev)->ofdev;
+	compat = (char *) get_property(of->node, "compatible", &cplen);
+	if (!compat) {
+		*buf = '\0';
+		return 0;
+	}
+	while (cplen > 0) {
+		int l;
+		length += sprintf (buf, "%s\n", compat);
+		buf += length;

This seems wrong. The above should be

	l = sprintf(buf + length, "%s\n", compat);
	length += l;
	buf += l;
Quoted 7 lines
sound/aoa/soundbus/sysfs.c new file +7 -0
+		l = strlen (compat) + 1;
+		compat += l;
+		cplen -= l;
+	}
+
+	return length;
+}

sound/aoa/soundbus/sysfs.c line 50

Quoted 10 lines
sound/aoa/soundbus/sysfs.c new file +10 -0
+
+static ssize_t modalias_show (struct device *dev, struct device_attribute *attr,
+			      char *buf)
+{
+	struct soundbus_dev *sdev = to_soundbus_device(dev);
+	struct of_device *of = &sdev->ofdev;
+	int length;
+
+	if (strlen(sdev->modalias)) {
+		length = snprintf (buf, 34, "%s\n", sdev->modalias);

sizeof(sdev->modalias) + 2? But still strange if modalias has no nul-end.

sound/aoa/soundbus/sysfs.c line 53

Quoted 3 lines
sound/aoa/soundbus/sysfs.c new file +3 -0
+	} else {
+		length = sprintf (buf, "of:N%sT%s\n", of->node->name, of->node->type);
+	}

Remove braces for single-line if (and too long).

Takashi

author maintainer
#7 lore raw

Re: [RFC 3/8] snd-aoa: add soundbus

Quoted 5 lines · Takashi Iwai

sound/aoa/soundbus/sysfs.c line 33

Quoted 3 lines
sound/aoa/soundbus/sysfs.c new file +3 -0
+		int l;
+		length += sprintf (buf, "%s\n", compat);
+		buf += length;

This seems wrong. The above should be

Heh, no idea where I copied that from but I sure didn't write it myself. Should be more careful next time I guess :)

Quoted 5 lines

sound/aoa/soundbus/sysfs.c line 50

Quoted 2 lines
sound/aoa/soundbus/sysfs.c new file +2 -0
+	if (strlen(sdev->modalias)) {
+		length = snprintf (buf, 34, "%s\n", sdev->modalias);

sizeof(sdev->modalias) + 2? But still strange if modalias has no nul-end.

Hm, how would I handle that if modalias has no nul?

johannes

_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

author maintainer
#8 lore raw

Re: [Alsa-devel] [RFC 3/8] snd-aoa: add soundbus

In reply to Takashi Iwai
Quoted 5 lines · Takashi Iwai

sound/aoa/soundbus/sysfs.c line 33

Quoted 3 lines
sound/aoa/soundbus/sysfs.c new file +3 -0
+		int l;
+		length += sprintf (buf, "%s\n", compat);
+		buf += length;

This seems wrong. The above should be

Heh, no idea where I copied that from but I sure didn't write it myself. Should be more careful next time I guess :)

Quoted 5 lines

sound/aoa/soundbus/sysfs.c line 50

Quoted 2 lines
sound/aoa/soundbus/sysfs.c new file +2 -0
+	if (strlen(sdev->modalias)) {
+		length = snprintf (buf, 34, "%s\n", sdev->modalias);

sizeof(sdev->modalias) + 2? But still strange if modalias has no nul-end.

Hm, how would I handle that if modalias has no nul?

johannes

#9 lore raw

Re: [RFC 3/8] snd-aoa: add soundbus

At Fri, 02 Jun 2006 16:07:05 +0200,

Quoted 9 lines · Johannes Berg
Quoted 5 lines · Takashi Iwai

sound/aoa/soundbus/sysfs.c line 50

Quoted 2 lines
sound/aoa/soundbus/sysfs.c new file +2 -0
+	if (strlen(sdev->modalias)) {
+		length = snprintf (buf, 34, "%s\n", sdev->modalias);

sizeof(sdev->modalias) + 2? But still strange if modalias has no nul-end.

Hm, how would I handle that if modalias has no nul?

Well, I'm not sure whether modalias is always nul-terminated. If yes (I hope so), the above could be simply sprintf().

Otherwise (if not nul-terminated), I'd implement like:

	strlcpy(buf, sdev->modalias, sizeof(sdev->modalias) + 1);
	strcpy(buf, "\n");
	lenth = strlen(buf);

Takashi

#10 lore raw

Re: [RFC 3/8] snd-aoa: add soundbus

Quoted 10 lines · Takashi Iwai

At Fri, 02 Jun 2006 16:07:05 +0200,

Quoted 8 lines · Johannes Berg
Quoted 5 lines · Takashi Iwai

sound/aoa/soundbus/sysfs.c line 50

Quoted 2 lines
sound/aoa/soundbus/sysfs.c new file +2 -0
+	if (strlen(sdev->modalias)) {
+		length = snprintf (buf, 34, "%s\n", sdev->modalias);

sizeof(sdev->modalias) + 2? But still strange if modalias has no nul-end.

Quoted 3 lines
Quoted 1 line

Hm, how would I handle that if modalias has no nul?

Well, I'm not sure whether modalias is always nul-terminated.

If modalias is not nul-terminated then strlen will already fail.

Quoted 4 lines

Otherwise (if not nul-terminated), I'd implement like:

	strlcpy(buf, sdev->modalias, sizeof(sdev->modalias) + 1);
	strcpy(buf, "\n");

strcat?

Andreas.

Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#12 lore raw

Re: [RFC 3/8] snd-aoa: add soundbus

In reply to Andreas Schwab

At Fri, 02 Jun 2006 16:41:14 +0200,

Quoted 13 lines · Andreas Schwab
Quoted 10 lines · Takashi Iwai

At Fri, 02 Jun 2006 16:07:05 +0200,

Quoted 8 lines · Johannes Berg
Quoted 5 lines · Takashi Iwai

sound/aoa/soundbus/sysfs.c line 50

Quoted 2 lines
sound/aoa/soundbus/sysfs.c new file +2 -0
+	if (strlen(sdev->modalias)) {
+		length = snprintf (buf, 34, "%s\n", sdev->modalias);

sizeof(sdev->modalias) + 2? But still strange if modalias has no nul-end.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Hm, how would I handle that if modalias has no nul?

Well, I'm not sure whether modalias is always nul-terminated.

If modalias is not nul-terminated then strlen will already fail.

Oh yes. It should be simply

	if (*sdev->modalias) {
		...
Quoted 6 lines
Quoted 4 lines

Otherwise (if not nul-terminated), I'd implement like:

	strlcpy(buf, sdev->modalias, sizeof(sdev->modalias) + 1);
	strcpy(buf, "\n");

strcat?

Argh, yes.

Takashi

author maintainer
#13 lore raw

RFC 4/8 snd-aoa: add i2sbus

In reply to Johannes Berg

This patch adds the required files for i2sbus (the Makefile hook and the Kconfig item were already added in the previous patch). i2sbus is the module that handles the i2s busses on newer Apple machines, currently only handling those machines that have all the required information in the device tree.

sound/aoa/soundbus/i2sbus/i2sbus-control.h new file +37 -0
@@ -0,0 +1,37 @@
+/*
+ * i2sbus driver -- bus register definitions
+ *
+ * Copyright 2006 Johannes Berg <[email protected]>
+ *
+ * GPL v2, can be found in COPYING.
+ */
+#ifndef __I2SBUS_CONTROLREGS_H
+#define __I2SBUS_CONTROLREGS_H
+
+/* i2s control registers, at least what we know about them */
+
+#define __PAD(m,n) u8 __pad##m[n]
+#define _PAD(line, n) __PAD(line, n)
+#define PAD(n) _PAD(__LINE__, (n))
+struct i2s_control_regs {
+	PAD(0x38);
+	__le32 fcr0;		/* 0x38 (unknown) */
+	__le32 cell_control;	/* 0x3c (fcr1) */
+	__le32 fcr2;		/* 0x40 (unknown) */
+	__le32 fcr3;		/* 0x44 (fcr3) */
+	__le32 clock_control;	/* 0x48 (unknown) */
+	PAD(4);
+	/* total size: 0x50 bytes */
+}  __attribute__((__packed__));
+
+#define CTRL_CLOCK_CELL_0_ENABLE	(1<<10)
+#define CTRL_CLOCK_CLOCK_0_ENABLE	(1<<12)
+#define CTRL_CLOCK_SWRESET_0		(1<<11)
+#define CTRL_CLOCK_INTF_0_ENABLE	(1<<13)
+
+#define CTRL_CLOCK_CELL_1_ENABLE	(1<<17)
+#define CTRL_CLOCK_CLOCK_1_ENABLE	(1<<18)
+#define CTRL_CLOCK_SWRESET_1		(1<<19)
+#define CTRL_CLOCK_INTF_1_ENABLE	(1<<20)
+
+#endif /* __I2SBUS_CONTROLREGS_H */
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +1008 -0

1,008 lines not on this page · raw message

sound/aoa/soundbus/i2sbus/i2sbus-core.c new file +387 -0

387 lines not on this page · raw message

sound/aoa/soundbus/i2sbus/i2sbus-interface.h new file +187 -0

187 lines not on this page · raw message

sound/aoa/soundbus/i2sbus/i2sbus.h new file +114 -0

114 lines not on this page · raw message

sound/aoa/soundbus/i2sbus/Makefile new file +2 -0
@@ -0,0 +1,2 @@
+obj-$(CONFIG_SND_AOA_SOUNDBUS_I2S) += snd-aoa-i2sbus.o
+snd-aoa-i2sbus-objs := i2sbus-core.o i2sbus-pcm.o i2sbus-control.o
sound/aoa/soundbus/i2sbus/i2sbus-control.c new file +192 -0

192 lines not on this page · raw message

--

#14 lore raw

Re: [RFC 4/8] snd-aoa: add i2sbus

At Thu, 01 Jun 2006 13:58:48 +0200,

Quoted 4 lines · Johannes Berg
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +1 -0
+static int clock_and_divisors(int mclk, int sclk, int rate, int *out)

sound/aoa/soundbus/i2sbus/i2sbus-pcm.c line 46

Quoted 10 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +10 -0
+{
+	/* sclk must be derived from mclk! */
+	if (mclk % sclk)
+		return -1;
+	/* derive sclk register value */
+	if (i2s_sf_sclkdiv(mclk / sclk, out))
+		return -1;
+
+	if (I2S_CLOCK_SPEED_18MHz % rate == 0) {
+		if ((I2S_CLOCK_SPEED_18MHz / rate) % mclk == 0) {

Equivalent with "I2S_CLOCK_SPEED_18MHZ % (rate * mclk) == 0" ?

Quoted 2 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +2 -0
+static int i2sbus_pcm_open(struct i2sbus_dev *i2sdev, int in)
+{

(snip)

sound/aoa/soundbus/i2sbus/i2sbus-pcm.c line 206

Quoted 6 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +6 -0
+	list_for_each_entry(cii, &sdev->codec_list, list) {
+		if (cii->codec->open) {
+			err = cii->codec->open(cii, pi->substream);
+			if (err) {
+				result = err;
+				goto out_unlock;

What happens if the first code is opened but fail the secondary? No need to close the first?

Quoted 45 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +45 -0
+static snd_pcm_uframes_t i2sbus_pcm_pointer(struct i2sbus_dev *i2sdev, int in)
+{
+	struct pcm_info *pi;
+	u32 fc;
+
+	get_pcm_info(i2sdev, in, &pi, NULL);
+
+	fc = in_le32(&i2sdev->intfregs->frame_count);
+	fc = fc - pi->frame_count;
+
+	return (bytes_to_frames(pi->substream->runtime,
+			       pi->current_period *
+			       snd_pcm_lib_period_bytes(pi->substream)) + fc) % pi->substream->runtime->buffer_size;
+}
+
+static inline void handle_interrupt(struct i2sbus_dev *i2sdev, int in)
+{
+	struct pcm_info *pi;
+	u32 fc;
+	u32 delta;
+
+	spin_lock(&i2sdev->low_lock);
+	get_pcm_info(i2sdev, in, &pi, NULL);
+	if (!pi->substream) {
+		printk(KERN_INFO "i2sbus: got %s irq while not active!\n",
+		       in ? "rx" : "tx");
+		goto out_unlock;
+	}
+
+	fc = in_le32(&i2sdev->intfregs->frame_count);
+	/* a counter overflow does not change the calculation. */
+	delta = fc - pi->frame_count;
+
+	/* update current_period */
+	while (delta >= pi->substream->runtime->period_size) {
+		pi->current_period++;
+		delta = delta - pi->substream->runtime->period_size;
+	}
+
+	if (unlikely(delta)) {
+		/* Some interrupt came late, so check the dbdma.
+		 * This special case exists to syncronize the frame_count with the
+		 * dbdma transfers, but is hit every once in a while. */
+		int period;
+

sound/aoa/soundbus/i2sbus/i2sbus-pcm.c line 614

Quoted 10 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +10 -0
+		period = (in_le32(&pi->dbdma->cmdptr) - pi->dbdma_ring.bus_cmd_start) / sizeof(struct dbdma_cmd);
+		pi->current_period = pi->current_period % pi->substream->runtime->periods;
+
+		while (pi->current_period != period) {
+			pi->current_period = (pi->current_period + 1) % pi->substream->runtime->periods;
+			/* Set delta to zero, as the frame_count value is too high (otherwise the code path
+			 * will not be executed).
+			 * This is to correct the fact that the frame_count is too low at the beginning
+			 * due to the dbdma's buffer. */
+			delta = 0;

Too long lines...

sound/aoa/soundbus/i2sbus/i2sbus-pcm.c line 810

Quoted 12 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +12 -0
+/* FIXME: this function needs an error handling strategy with labels */
+int
+i2sbus_attach_codec(struct soundbus_dev *dev, struct snd_card *card,
+		    struct codec_info *ci, void *data)
+{
+	int err, in = 0, out = 0;
+	struct transfer_info *tmp;
+	struct i2sbus_dev *i2sdev = soundbus_dev_to_i2sbus_dev(dev);
+	struct codec_info_item *cii;
+
+	if (!dev->pcmname || dev->pcmid == -1) {
+		printk(KERN_ERR "i2sbus: pcm name and id must be set!\n");

No error return?

sound/aoa/soundbus/i2sbus/i2sbus-pcm.c line 983

Quoted 9 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +9 -0
+	/* well, we really should support scatter/gather DMA */
+	/* FIXME FIXME FIXME: If this fails, we BUG() when the alsa layer
+	 * later tries to allocate memory. Apparently we should be setting
+	 * some device pointer for that ...
+	 */
+	snd_pcm_lib_preallocate_pages_for_all(
+		dev->pcm, SNDRV_DMA_TYPE_DEV,
+		snd_dma_pci_data(macio_get_pci_dev(i2sdev->macio)),
+		64 * 1024, 64 * 1024);

Is the comment true? Yes, you have to set the device pointer via snd_pcm_lib_preallocate*(). But it must be OK even if preallocate fails.

Quoted 4 lines
sound/aoa/soundbus/i2sbus/i2sbus-core.c new file +2 -0
+static int alloc_dbdma_descriptor_ring(struct i2sbus_dev *i2sdev,
+				       struct dbdma_command_mem *r,

sound/aoa/soundbus/i2sbus/i2sbus-core.c line 43

Quoted 10 lines
sound/aoa/soundbus/i2sbus/i2sbus-core.c new file +10 -0
+				       int numcmds)
+{
+	/* one more for rounding */
+	r->size = (numcmds+1) * sizeof(struct dbdma_cmd);
+	/* We use the PCI APIs for now until the generic one gets fixed
+	 * enough or until we get some macio-specific versions
+	 */
+	r->space = pci_alloc_consistent(macio_get_pci_dev(i2sdev->macio),
+					r->size,
+					&r->bus_addr);

Better to use dma_alloc_coherent(). pci_alloc_consistent() implies GFP_ATOMIC.

sound/aoa/soundbus/i2sbus/i2sbus-core.c line 94

Quoted 9 lines
sound/aoa/soundbus/i2sbus/i2sbus-core.c new file +9 -0
+static irqreturn_t i2sbus_bus_intr(int irq, void *devid, struct pt_regs *regs)
+{
+	struct i2sbus_dev *dev = devid;
+	u32 intreg;
+
+	spin_lock(&dev->low_lock);
+	intreg = in_le32(&dev->intfregs->intr_ctl);
+
+	printk(KERN_INFO "i2sbus: interrupt, intr reg is 0x%x!\n", intreg);

Should this be really always printed?

Takashi

author maintainer
#15 lore raw

Re: [RFC 4/8] snd-aoa: add i2sbus

Quoted 4 lines · Takashi Iwai

sound/aoa/soundbus/i2sbus/i2sbus-pcm.c line 46

Quoted 2 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +2 -0
+	if (I2S_CLOCK_SPEED_18MHz % rate == 0) {
+		if ((I2S_CLOCK_SPEED_18MHz / rate) % mclk == 0) {

Equivalent with "I2S_CLOCK_SPEED_18MHZ % (rate * mclk) == 0" ?

Yeah, I guess, never really thought about that, just wrote it down the way I thought to do it :) That said, I think it's more readable if written that way, do you want me to change it regardless?

Quoted 9 lines

sound/aoa/soundbus/i2sbus/i2sbus-pcm.c line 206

Quoted 6 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +6 -0
+	list_for_each_entry(cii, &sdev->codec_list, list) {
+		if (cii->codec->open) {
+			err = cii->codec->open(cii, pi->substream);
+			if (err) {
+				result = err;
+				goto out_unlock;

What happens if the first code is opened but fail the secondary? No need to close the first?

Yes, that needs to be done, good catch.

Quoted 5 lines
Quoted 5 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +5 -0
+	/* well, we really should support scatter/gather DMA */
+	/* FIXME FIXME FIXME: If this fails, we BUG() when the alsa layer
+	 * later tries to allocate memory. Apparently we should be setting
+	 * some device pointer for that ...
+	 */
Quoted 8 lines

sound/aoa/soundbus/i2sbus/i2sbus-pcm.c line 983

Quoted 4 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +4 -0
+	snd_pcm_lib_preallocate_pages_for_all(
+		dev->pcm, SNDRV_DMA_TYPE_DEV,
+		snd_dma_pci_data(macio_get_pci_dev(i2sdev->macio)),
+		64 * 1024, 64 * 1024);

Is the comment true? Yes, you have to set the device pointer via snd_pcm_lib_preallocate*(). But it must be OK even if preallocate fails.

Hah, I don't know actually, I didn't know you set the pointer using this function, when I wrote the comment I just had forgotten the preallocate call!
Does that mean that _preallocate_pages_for_all() has the side effect of setting the pointer? If so, imho that's pretty bad.

Quoted 11 lines

sound/aoa/soundbus/i2sbus/i2sbus-core.c line 94

Quoted 9 lines
sound/aoa/soundbus/i2sbus/i2sbus-core.c new file +9 -0
+static irqreturn_t i2sbus_bus_intr(int irq, void *devid, struct pt_regs *regs)
+{
+	struct i2sbus_dev *dev = devid;
+	u32 intreg;
+
+	spin_lock(&dev->low_lock);
+	intreg = in_le32(&dev->intfregs->intr_ctl);
+
+	printk(KERN_INFO "i2sbus: interrupt, intr reg is 0x%x!\n", intreg);

Should this be really always printed?

no, gone.

johannes

_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

author maintainer
#16 lore raw

Re: [Alsa-devel] [RFC 4/8] snd-aoa: add i2sbus

In reply to Takashi Iwai
Quoted 4 lines · Takashi Iwai

sound/aoa/soundbus/i2sbus/i2sbus-pcm.c line 46

Quoted 2 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +2 -0
+	if (I2S_CLOCK_SPEED_18MHz % rate == 0) {
+		if ((I2S_CLOCK_SPEED_18MHz / rate) % mclk == 0) {

Equivalent with "I2S_CLOCK_SPEED_18MHZ % (rate * mclk) == 0" ?

Yeah, I guess, never really thought about that, just wrote it down the way I thought to do it :) That said, I think it's more readable if written that way, do you want me to change it regardless?

Quoted 9 lines

sound/aoa/soundbus/i2sbus/i2sbus-pcm.c line 206

Quoted 6 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +6 -0
+	list_for_each_entry(cii, &sdev->codec_list, list) {
+		if (cii->codec->open) {
+			err = cii->codec->open(cii, pi->substream);
+			if (err) {
+				result = err;
+				goto out_unlock;

What happens if the first code is opened but fail the secondary? No need to close the first?

Yes, that needs to be done, good catch.

Quoted 5 lines
Quoted 5 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +5 -0
+	/* well, we really should support scatter/gather DMA */
+	/* FIXME FIXME FIXME: If this fails, we BUG() when the alsa layer
+	 * later tries to allocate memory. Apparently we should be setting
+	 * some device pointer for that ...
+	 */
Quoted 8 lines

sound/aoa/soundbus/i2sbus/i2sbus-pcm.c line 983

Quoted 4 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +4 -0
+	snd_pcm_lib_preallocate_pages_for_all(
+		dev->pcm, SNDRV_DMA_TYPE_DEV,
+		snd_dma_pci_data(macio_get_pci_dev(i2sdev->macio)),
+		64 * 1024, 64 * 1024);

Is the comment true? Yes, you have to set the device pointer via snd_pcm_lib_preallocate*(). But it must be OK even if preallocate fails.

Hah, I don't know actually, I didn't know you set the pointer using this function, when I wrote the comment I just had forgotten the preallocate call!
Does that mean that _preallocate_pages_for_all() has the side effect of setting the pointer? If so, imho that's pretty bad.

Quoted 11 lines

sound/aoa/soundbus/i2sbus/i2sbus-core.c line 94

Quoted 9 lines
sound/aoa/soundbus/i2sbus/i2sbus-core.c new file +9 -0
+static irqreturn_t i2sbus_bus_intr(int irq, void *devid, struct pt_regs *regs)
+{
+	struct i2sbus_dev *dev = devid;
+	u32 intreg;
+
+	spin_lock(&dev->low_lock);
+	intreg = in_le32(&dev->intfregs->intr_ctl);
+
+	printk(KERN_INFO "i2sbus: interrupt, intr reg is 0x%x!\n", intreg);

Should this be really always printed?

no, gone.

johannes

#17 lore raw

Re: [RFC 4/8] snd-aoa: add i2sbus

At Tue, 06 Jun 2006 13:17:27 +0200,

Quoted 10 lines · Johannes Berg
Quoted 4 lines · Takashi Iwai

sound/aoa/soundbus/i2sbus/i2sbus-pcm.c line 46

Quoted 2 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +2 -0
+	if (I2S_CLOCK_SPEED_18MHz % rate == 0) {
+		if ((I2S_CLOCK_SPEED_18MHz / rate) % mclk == 0) {

Equivalent with "I2S_CLOCK_SPEED_18MHZ % (rate * mclk) == 0" ?

Yeah, I guess, never really thought about that, just wrote it down the way I thought to do it :) That said, I think it's more readable if written that way, do you want me to change it regardless?

I found a single if is more readable (and good for compiler).

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +5 -0
+	/* well, we really should support scatter/gather DMA */
+	/* FIXME FIXME FIXME: If this fails, we BUG() when the alsa layer
+	 * later tries to allocate memory. Apparently we should be setting
+	 * some device pointer for that ...
+	 */
Quoted 8 lines

sound/aoa/soundbus/i2sbus/i2sbus-pcm.c line 983

Quoted 4 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +4 -0
+	snd_pcm_lib_preallocate_pages_for_all(
+		dev->pcm, SNDRV_DMA_TYPE_DEV,
+		snd_dma_pci_data(macio_get_pci_dev(i2sdev->macio)),
+		64 * 1024, 64 * 1024);

Is the comment true? Yes, you have to set the device pointer via snd_pcm_lib_preallocate*(). But it must be OK even if preallocate fails.

Quoted 5 lines

Hah, I don't know actually, I didn't know you set the pointer using this function, when I wrote the comment I just had forgotten the preallocate call!
Does that mean that _preallocate_pages_for_all() has the side effect of setting the pointer? If so, imho that's pretty bad.

No, the only requirement is that you have to call snd_pcm_lib_malloc() with proper type and assigned device pointer if you use snd_pcm_lib_malloc() function. (If not called, you've got an error when compiled with debug option.)

Takashi

#18 lore raw

Re: [Alsa-devel] [RFC 4/8] snd-aoa: add i2sbus

In reply to Johannes Berg

At Tue, 06 Jun 2006 13:17:27 +0200,

Quoted 10 lines · Johannes Berg
Quoted 4 lines · Takashi Iwai

sound/aoa/soundbus/i2sbus/i2sbus-pcm.c line 46

Quoted 2 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +2 -0
+	if (I2S_CLOCK_SPEED_18MHz % rate == 0) {
+		if ((I2S_CLOCK_SPEED_18MHz / rate) % mclk == 0) {

Equivalent with "I2S_CLOCK_SPEED_18MHZ % (rate * mclk) == 0" ?

Yeah, I guess, never really thought about that, just wrote it down the way I thought to do it :) That said, I think it's more readable if written that way, do you want me to change it regardless?

I found a single if is more readable (and good for compiler).

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +5 -0
+	/* well, we really should support scatter/gather DMA */
+	/* FIXME FIXME FIXME: If this fails, we BUG() when the alsa layer
+	 * later tries to allocate memory. Apparently we should be setting
+	 * some device pointer for that ...
+	 */
Quoted 8 lines

sound/aoa/soundbus/i2sbus/i2sbus-pcm.c line 983

Quoted 4 lines
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c new file +4 -0
+	snd_pcm_lib_preallocate_pages_for_all(
+		dev->pcm, SNDRV_DMA_TYPE_DEV,
+		snd_dma_pci_data(macio_get_pci_dev(i2sdev->macio)),
+		64 * 1024, 64 * 1024);

Is the comment true? Yes, you have to set the device pointer via snd_pcm_lib_preallocate*(). But it must be OK even if preallocate fails.

Quoted 5 lines

Hah, I don't know actually, I didn't know you set the pointer using this function, when I wrote the comment I just had forgotten the preallocate call!
Does that mean that _preallocate_pages_for_all() has the side effect of setting the pointer? If so, imho that's pretty bad.

No, the only requirement is that you have to call snd_pcm_lib_malloc() with proper type and assigned device pointer if you use snd_pcm_lib_malloc() function. (If not called, you've got an error when compiled with debug option.)

Takashi

author maintainer
#19 lore raw

Re: [RFC 4/8] snd-aoa: add i2sbus

Quoted 5 lines · Takashi Iwai
Quoted 3 lines

Yeah, I guess, never really thought about that, just wrote it down the way I thought to do it :) That said, I think it's more readable if written that way, do you want me to change it regardless?

I found a single if is more readable (and good for compiler).

Heh ok, I'll change it, it isn't really hard to read either way.

Quoted 4 lines

No, the only requirement is that you have to call snd_pcm_lib_malloc() with proper type and assigned device pointer if you use snd_pcm_lib_malloc() function. (If not called, you've got an error when compiled with debug option.)

Ok, but how do I set the device pointer?

johannes

#20 lore raw

Re: [RFC 4/8] snd-aoa: add i2sbus

At Wed, 07 Jun 2006 13:40:21 +0200,

Quoted 12 lines · Johannes Berg
Quoted 5 lines · Takashi Iwai
Quoted 3 lines

Yeah, I guess, never really thought about that, just wrote it down the way I thought to do it :) That said, I think it's more readable if written that way, do you want me to change it regardless?

I found a single if is more readable (and good for compiler).

Heh ok, I'll change it, it isn't really hard to read either way.

Quoted 6 lines
Quoted 4 lines

No, the only requirement is that you have to call snd_pcm_lib_malloc() with proper type and assigned device pointer if you use snd_pcm_lib_malloc() function. (If not called, you've got an error when compiled with debug option.)

Ok, but how do I set the device pointer?

Your code already does it. The macro pci_to_dev() retrieves struct device pointer (it's just for compatibility with older kernels).

Takashi

author maintainer
#21 lore raw

Re: [RFC 4/8] snd-aoa: add i2sbus

Quoted 3 lines · Takashi Iwai
Quoted 1 line

Ok, but how do I set the device pointer?

Your code already does it.

Where? Am I just missing something? I don't see where I use pci_to_dev nor setting any device pointer.

The thing the comment noted was that if I left out the call to snd_pcm_lib_preallocate_pages_for_all, it would later oops somewhere.

johannes

#22 lore raw

Re: [RFC 4/8] snd-aoa: add i2sbus

At Wed, 07 Jun 2006 14:45:00 +0200,

Quoted 8 lines · Johannes Berg
Quoted 3 lines · Takashi Iwai
Quoted 1 line

Ok, but how do I set the device pointer?

Your code already does it.

Where? Am I just missing something? I don't see where I use pci_to_dev nor setting any device pointer.

Sorry, s/pci_to_dev/snd_dma_pci_data/

Takashi

author maintainer
#23 lore raw

Re: [RFC 4/8] snd-aoa: add i2sbus

Quoted 1 line · Takashi Iwai

Sorry, s/pci_to_dev/snd_dma_pci_data/

So then you're saying that indeed, snd_pcm_lib_preallocate_pages_for_all has the side effect of setting a pointer somewhere else?

I just don't understand why it all blows up when I leave off the preallocate call. From the function name that says 'preallocate pages' it seemed to me that I should be allowed to just leave it off, risking that later an open() or prepare() fails because no pages could be allocated.

johannes

_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

#24 lore raw

Re: [RFC 4/8] snd-aoa: add i2sbus

At Wed, 07 Jun 2006 14:52:25 +0200,

Quoted 7 lines · Johannes Berg
Quoted 1 line · Takashi Iwai

Sorry, s/pci_to_dev/snd_dma_pci_data/

So then you're saying that indeed, snd_pcm_lib_preallocate_pages_for_all has the side effect of setting a pointer somewhere else?

Well, I don't understand what you mean "side-effect" here.

The device pointer is passed to the memory allocator, so if you pass a bogus value there, it'll cause surely oops.

Quoted 5 lines

I just don't understand why it all blows up when I leave off the preallocate call. From the function name that says 'preallocate pages' it seemed to me that I should be allowed to just leave it off, risking that later an open() or prepare() fails because no pages could be allocated.

IIF you use snd_pcm_lib_malloc_pages(), the pre-allocation is mandatory. That's the definition.
(And, as mentioned, snd_pcm_lib_malloc_pages() checks the pre-allocation when debug option is set. If you don't set the debug option, it assumes that the pre-allocation was already executed.)

You're free to use dma_alloc_coherent() or whatever in hw_params callback.

Takashi

#25 lore raw

Re: [Alsa-devel] [RFC 4/8] snd-aoa: add i2sbus

In reply to Johannes Berg

At Wed, 07 Jun 2006 14:52:25 +0200,

Quoted 7 lines · Johannes Berg
Quoted 1 line · Takashi Iwai

Sorry, s/pci_to_dev/snd_dma_pci_data/

So then you're saying that indeed, snd_pcm_lib_preallocate_pages_for_all has the side effect of setting a pointer somewhere else?

Well, I don't understand what you mean "side-effect" here.

The device pointer is passed to the memory allocator, so if you pass a bogus value there, it'll cause surely oops.

Quoted 5 lines

I just don't understand why it all blows up when I leave off the preallocate call. From the function name that says 'preallocate pages' it seemed to me that I should be allowed to just leave it off, risking that later an open() or prepare() fails because no pages could be allocated.

IIF you use snd_pcm_lib_malloc_pages(), the pre-allocation is mandatory. That's the definition.
(And, as mentioned, snd_pcm_lib_malloc_pages() checks the pre-allocation when debug option is set. If you don't set the debug option, it assumes that the pre-allocation was already executed.)

You're free to use dma_alloc_coherent() or whatever in hw_params callback.

Takashi

author maintainer
#26 lore raw

Re: [RFC 4/8] snd-aoa: add i2sbus

Quoted 4 lines · Takashi Iwai

Well, I don't understand what you mean "side-effect" here.

The device pointer is passed to the memory allocator, so if you pass a bogus value there, it'll cause surely oops.

Ok. I misunderstood what the function does. Sorry for the noise and thanks for explaining.

johannes

_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

author maintainer
#27 lore raw

RFC 5/8 snd-aoa: add codecs

In reply to Johannes Berg

This patch adds two of the most important codecs Apple uses in newer machines, namely the Onyx and the tas3004.

sound/aoa/codecs/Makefile new file +2 -0
@@ -0,0 +1,2 @@
+obj-$(CONFIG_SND_AOA_ONYX) += snd-aoa-codec-onyx.o
+obj-$(CONFIG_SND_AOA_TAS) += snd-aoa-codec-tas.o
sound/aoa/codecs/snd-aoa-codec-onyx.h new file +76 -0

76 lines not on this page · raw message

sound/aoa/codecs/snd-aoa-codec-tas-gain-table.h new file +209 -0

209 lines not on this page · raw message

sound/aoa/codecs/snd-aoa-codec-tas.h new file +47 -0

47 lines not on this page · raw message

sound/aoa/codecs/snd-aoa-codec-onyx.c new file +1116 -0

1,116 lines not on this page · raw message

sound/aoa/codecs/Kconfig new file +24 -0
@@ -0,0 +1,24 @@
+config SND_AOA_ONYX
+	tristate "support Onyx chip"
+	depends on SND_AOA
+	---help---
+	This option enables support for the Onyx (pcm3052)
+	codec chip found in the latest Apple machines
+	(most of those with digital audio output).
+
+#config SND_AOA_TOPAZ
+#	tristate "support Topaz chips"
+#	depends on SND_AOA
+#	---help---
+#	This option enables support for the Topaz (CS84xx)
+#	codec chips found in the latest Apple machines,
+#	these chips do the digital input and output on
+#	some PowerMacs.
+
+config SND_AOA_TAS
+	tristate "support TAS chips"
+	depends on SND_AOA
+	---help---
+	This option enables support for the tas chips
+	found in a lot of Apple Machines, especially
+	iBooks and PowerBooks without digital.
sound/aoa/codecs/snd-aoa-codec-tas.c new file +647 -0

647 lines not on this page · raw message

--

#28 lore raw

Re: [RFC 5/8] snd-aoa: add codecs

At Thu, 01 Jun 2006 13:58:49 +0200,

Quoted 13 lines · Johannes Berg
sound/aoa/codecs/snd-aoa-codec-tas-gain-table.h new file +9 -0
@@ -0,0 +1,209 @@
+/*
+ This is the program used to generate below table.
+
+#include <stdio.h>
+#include <math.h>
+int main() {
+  int dB2;
+  printf("/" "* This file is only included exactly once!\n");
+  printf(" *\n");

sound/aoa/codecs/snd-aoa-codec-tas-gain-table.h line 19

Quoted 10 lines
sound/aoa/codecs/snd-aoa-codec-tas-gain-table.h new file +10 -0
+  printf(" * If they'd only tell us that generating this table was\n");
+  printf(" * as easy as calculating\n");
+  printf(" *      hwvalue = 1048576.0*exp(0.057564628*dB*2)\n");
+  printf(" * :) *" "/\n");
+  printf("static int tas_gaintable[] = {\n");
+  printf("	0x000000, /" "* -infinity dB *" "/\n");
+  for (dB2=-140;dB2<=36;dB2++)
+    printf("	0x%.6x, /" "* %-02.1f dB *" "/\n", (int)(1048576.0*exp(0.057564628*dB2)), dB2/2.0);
+  printf("};\n\n");
+}

FYI: We're currently implementing a dB conversion. So, this will be unneeded in future.

But I'll included this as it is now at committing, and fix the dB things later.

Takashi

author maintainer
#29 lore raw

Re: [RFC 5/8] snd-aoa: add codecs

Quoted 2 lines · Takashi Iwai

FYI: We're currently implementing a dB conversion. So, this will be unneeded in future.

Cool, good to know :)

Quoted 2 lines

But I'll included this as it is now at committing, and fix the dB things later.

Ok.

johannes

_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

author maintainer
#30 lore raw

Re: [Alsa-devel] [RFC 5/8] snd-aoa: add codecs

In reply to Takashi Iwai
Quoted 2 lines · Takashi Iwai

FYI: We're currently implementing a dB conversion. So, this will be unneeded in future.

Cool, good to know :)

Quoted 2 lines

But I'll included this as it is now at committing, and fix the dB things later.

Ok.

johannes

author maintainer
#31 lore raw

RFC 6/8 snd-aoa: add layout-id fabric

In reply to Johannes Berg

The 'fabric' is the thing that pulls all of snd-aoa together, this patch adds the 'layout' or 'layout-id' fabric that keys off the 'layout-id' property in the device-tree to pull in the proper modules. It itself loads if an i2sbus is present with a layout-id (exported in modalias) that it can use.

sound/aoa/fabrics/Makefile new file +1 -0
@@ -0,0 +1 @@
+obj-$(CONFIG_SND_AOA_FABRIC_LAYOUT) += snd-aoa-fabric-layout.o
sound/aoa/fabrics/Kconfig new file +12 -0
@@ -0,0 +1,12 @@
+config SND_AOA_FABRIC_LAYOUT
+	tristate "layout-id fabric"
+	depends SND_AOA
+	select SND_AOA_SOUNDBUS
+	select SND_AOA_SOUNDBUS_I2S
+	---help---
+	This enables the layout-id fabric for the Apple Onboard
+	Audio driver, the module holding it all together
+	based on the device-tree's layout-id property.
+	
+	If you are unsure and have a later Apple machine,
+	compile it as a module.
sound/aoa/fabrics/snd-aoa-fabric-layout.c new file +889 -0

889 lines not on this page · raw message

--

author maintainer
#32 lore raw

RFC 7/8 snd-aoa: add Kconfig and Makefile

In reply to Johannes Berg

This patch adds the simple Kconfig and Makefile files for aoa.

sound/aoa/Kconfig new file +17 -0
@@ -0,0 +1,17 @@
+menu "Apple Onboard Audio driver"
+	depends on SND != n && PPC
+
+config SND_AOA
+	tristate "Apple Onboard Audio driver"
+	depends on SOUND && SND_PCM && EXPERIMENTAL
+	---help---
+	This option enables the new driver for the various
+	Apple Onboard Audio components.
+
+source "sound/aoa/fabrics/Kconfig"
+
+source "sound/aoa/codecs/Kconfig"
+
+source "sound/aoa/soundbus/Kconfig"
+
+endmenu
sound/aoa/Makefile new file +4 -0
@@ -0,0 +1,4 @@
+obj-$(CONFIG_SND_AOA) += core/
+obj-$(CONFIG_SND_AOA) += codecs/
+obj-$(CONFIG_SND_AOA) += fabrics/
+obj-$(CONFIG_SND_AOA_SOUNDBUS) += soundbus/

--

author maintainer
#33 lore raw

RFC 8/8 snd-aoa: wire up aoa in sound/

In reply to Johannes Berg

This patch adds the necessary Kconfig and Makefile hooks to make aoa buildable inside the kernel tree.

sound/Kconfig +2 -0
@@ -58,6 +58,8 @@ source "sound/pci/Kconfig"
 
 source "sound/ppc/Kconfig"
 
+source "sound/aoa/Kconfig"
+
 source "sound/arm/Kconfig"
 
 source "sound/mips/Kconfig"
sound/Makefile +1 -1
@@ -4,7 +4,7 @@ #
 obj-$(CONFIG_SOUND) += soundcore.o
 obj-$(CONFIG_SOUND_PRIME) += oss/
 obj-$(CONFIG_DMASOUND) += oss/
-obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ synth/ usb/ sparc/ parisc/ pcmcia/ mips/
+obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ synth/ usb/ sparc/ parisc/ pcmcia/ mips/ aoa/
 
 ifeq ($(CONFIG_SND),y)
   obj-y += last.o

--

#34 lore raw
In reply to Johannes Berg

At Thu, 01 Jun 2006 13:58:44 +0200,

Quoted 11 lines · Johannes Berg

The following patches would add snd-aoa to the Linux source tree. I'm posting them here in the spirit of getting review fairly early, it works fine for those machines it handles and even implements headphone/line-out detection now.

One thing that still needs to be done is fix this on the mac-mini where apparently some things are missing from the device-tree, and on the PowerMac7,2/7,3 where the device tree has a bug that prevents the i2sbus module from working properly.

Quoted 7 lines

Other than that, it replaces snd-powermac for all layout-id machines, and handles many more already, so once those two issues are fixed I'll also add a patch to this patchset that removes support for any machines with a layout-id from snd-powermac to allow snd-aoa and snd-powermac to coexist nicely.

Any comments are appreciated.

As already posted, there are small glitches, but it looks otherwise good enough to merge.

Would you like to commit the patches as one changeset or separate? Anyway, please provide a changelog and a signed-off-by line for proper commit.

thanks,

Takashi

author maintainer
#35 lore raw
Quoted 2 lines · Takashi Iwai

As already posted, there are small glitches, but it looks otherwise good enough to merge.

Right, I'll post updates (also have a few small changes locally)

Quoted 1 line

Would you like to commit the patches as one changeset or separate?

I guess it doesn't make much sense to commit them in separate changesets as they depend on each other, I just split it up for making it easier to review.

Quoted 2 lines

Anyway, please provide a changelog and a signed-off-by line for proper commit.

Obviously, but I didn't think that was necessary for review.

Also, what with further development? I have this in a git tree and will continue using it, should I just push patches regularly?

johannes

_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

#36 lore raw

At Fri, 02 Jun 2006 16:56:05 +0200,

Quoted 6 lines · Johannes Berg
Quoted 2 lines · Takashi Iwai

As already posted, there are small glitches, but it looks otherwise good enough to merge.

Quoted 7 lines

Right, I'll post updates (also have a few small changes locally)

Quoted 1 line

Would you like to commit the patches as one changeset or separate?

I guess it doesn't make much sense to commit them in separate changesets as they depend on each other, I just split it up for making it easier to review.

OK.

Quoted 7 lines
Quoted 2 lines

Anyway, please provide a changelog and a signed-off-by line for proper commit.

Obviously, but I didn't think that was necessary for review.

Also, what with further development? I have this in a git tree and will continue using it, should I just push patches regularly?

Please post patches to alsa-devel ML. It's easier for us to review.

Takashi

#37 lore raw
In reply to Johannes Berg

At Fri, 02 Jun 2006 16:56:05 +0200,

Quoted 6 lines · Johannes Berg
Quoted 2 lines · Takashi Iwai

As already posted, there are small glitches, but it looks otherwise good enough to merge.

Quoted 7 lines

Right, I'll post updates (also have a few small changes locally)

Quoted 1 line

Would you like to commit the patches as one changeset or separate?

I guess it doesn't make much sense to commit them in separate changesets as they depend on each other, I just split it up for making it easier to review.

OK.

Quoted 7 lines
Quoted 2 lines

Anyway, please provide a changelog and a signed-off-by line for proper commit.

Obviously, but I didn't think that was necessary for review.

Also, what with further development? I have this in a git tree and will continue using it, should I just push patches regularly?

Please post patches to alsa-devel ML. It's easier for us to review.

Takashi