Skip to contentSkip to conversation

N900 Modem Speech Support

PATCH In review Sebastian Reichel 2 participants 7 messages Mar 21, 2015 – Mar 31, 2015

Subsystems (2)
lore
Share & tools
lore

Sebastian Reichel

author maintainer
#0 lore raw

v3 cover N900 Modem Speech Support

Hi,

This patchset contains the missing speech data support for the Nokia N900 modem.

Userland access goes via /dev/cmt_speech. The API is implemented in libcmtspeechdata, which is used by ofono and the freesmartphone.org project. Apart from that the device is also used by the phone binaries distributed with Maemo. So while this is a new userland ABI for the mainline kernel it has been tested in the wild for some years.

Simple Testing of the API can be done by checking out libcmtspeechdata [0], building the test tool and executing it. The tool will loop back audio data received from the caller.

I have prepared a kernel branch for this patchset, which can be found at [1].

Changes since PATCHv2 [3]:
* Change MODULE_LICENSE from "GPL" to "GPL v2"
* Add some cleanups suggested by Pavel
* Add missing dependency on SSI_PROTOCOL in Kconfig

Changes since PATCHv1 [2]:
* Squash cmt-speech patches together
* cs_alloc_cmds(): GFP_ATOMIC -> GFP_KERNEL
* CS_SET_WAKELINE ioctl: Add sanity check

[0] https://lkml.org/lkml/2015/2/11/526
[1] git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-hsi.git branch/cmt-speech-2
[2] https://lkml.org/lkml/2015/3/1/282
[3] https://lkml.org/lkml/2015/3/4/1139

-- Sebastian

Kai Vehmanen (1):
HSI: cmt_speech: Add cmt-speech driver

Sebastian Reichel (1):
HSI: nokia-modem: Add cmt-speech support

 drivers/hsi/clients/Kconfig          |   12 +-
 drivers/hsi/clients/Makefile         |    1 +
 drivers/hsi/clients/cmt_speech.c     | 1456 ++++++++++++++++++++++++++++++++++
 drivers/hsi/clients/nokia-modem.c    |   32 +-
 include/uapi/linux/hsi/Kbuild        |    2 +-
 include/uapi/linux/hsi/cs-protocol.h |  113 +++
 6 files changed, 1613 insertions(+), 3 deletions(-)
 create mode 100644 drivers/hsi/clients/cmt_speech.c
 create mode 100644 include/uapi/linux/hsi/cs-protocol.h
Signature · 1 line
2.1.4
author maintainer
#1 lore raw

PATCH v3 1/2 HSI: cmt_speech: Add cmt-speech driver

From: Kai Vehmanen <[email protected]>

Introduces the cmt-speech driver, which implements a character device interface for transferring speech data frames over HSI/SSI.

The driver is used to exchange voice/speech data between the Nokia N900/N950/N9's modem and its cpu.

Since the original driver has been written for 2.6.28 some build fixes and general cleanups have been added by me:

* fix build for 4.0 kernel
* replace GFP_ATOMIC with GFP_KERNEL in cs_alloc_cmds()
* add sanity check for CS_SET_WAKELINE ioctl
* cleanup driver initialisation
* rename driver to cmt-speech to be consistent with ssi-protocol driver
* move cs-protocol.h to include/uapi/linux/hsi, since it describes a userspace API
* replace hardcoded channels numbers with values provided via the HSI framework (e.g. coming from DT)

---
 drivers/hsi/clients/Kconfig          |   10 +
 drivers/hsi/clients/Makefile         |    1 +
 drivers/hsi/clients/cmt_speech.c     | 1456 ++++++++++++++++++++++++++++++++++
 include/uapi/linux/hsi/Kbuild        |    2 +-
 include/uapi/linux/hsi/cs-protocol.h |  113 +++
 5 files changed, 1581 insertions(+), 1 deletion(-)
 create mode 100644 drivers/hsi/clients/cmt_speech.c
 create mode 100644 include/uapi/linux/hsi/cs-protocol.h
drivers/hsi/clients/Kconfig +10 -0
index bc60dec..86c8495 100644
@@ -13,6 +13,16 @@ config NOKIA_MODEM
 
 	If unsure, say N.
 
+config CMT_SPEECH
+	tristate "CMT speech"
+	depends on HSI && SSI_PROTOCOL
+	help
+	If you say Y here, you will enable the CMT speech protocol used
+	by Nokia modems. If you say M the protocol will be available as
+	module named cmt_speech.
+
+	If unsure, say N.
+
 config SSI_PROTOCOL
 	tristate "SSI protocol"
 	depends on HSI && PHONET && OMAP_SSI
drivers/hsi/clients/Makefile +1 -0
index 4d5bc0e..2607232 100644
@@ -4,4 +4,5 @@
 
 obj-$(CONFIG_NOKIA_MODEM)	+= nokia-modem.o
 obj-$(CONFIG_SSI_PROTOCOL)	+= ssi_protocol.o
+obj-$(CONFIG_CMT_SPEECH)	+= cmt_speech.o
 obj-$(CONFIG_HSI_CHAR)		+= hsi_char.o
drivers/hsi/clients/cmt_speech.c new file +1456 -0

1,456 lines not on this page · raw message

include/uapi/linux/hsi/Kbuild +1 -1
index 30ab3cd..a16a005 100644
@@ -1,2 +1,2 @@
 # UAPI Header export list
-header-y += hsi_char.h
+header-y += hsi_char.h cs-protocol.h
include/uapi/linux/hsi/cs-protocol.h new file +113 -0

113 lines not on this page · raw message

Signature · 1 line
2.1.4
Acked-by on v3 1/2
#2 lore raw

Re: [PATCHv3 1/2] HSI: cmt_speech: Add cmt-speech driver

Hi,

Quoted 6 lines · Sebastian Reichel

From: Kai Vehmanen <[email protected]>

Introduces the cmt-speech driver, which implements a character device interface for transferring speech data frames over HSI/SSI.

Quoted 6 lines

The driver is used to exchange voice/speech data between the Nokia N900/N950/N9's modem and its cpu.

A.

author maintainer
#3 lore raw

PATCH v3 2/2 HSI: nokia-modem: Add cmt-speech support

In reply to Sebastian Reichel

Register cmt-speech driver in nokia-modem driver and forward hsi channel information.

---
 drivers/hsi/clients/Kconfig       |  2 +-
 drivers/hsi/clients/nokia-modem.c | 32 +++++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 2 deletions(-)
drivers/hsi/clients/Kconfig +1 -1
index 86c8495..d612620 100644
@@ -6,7 +6,7 @@ comment "HSI clients"
 
 config NOKIA_MODEM
 	tristate "Nokia Modem"
-	depends on HSI && SSI_PROTOCOL
+	depends on HSI && SSI_PROTOCOL && CMT_SPEECH
 	help
 	Say Y here if you want to add support for the modem on Nokia
 	N900 (Nokia RX-51) hardware.
drivers/hsi/clients/nokia-modem.c +31 -1
index 9be4867..bbb1923 100644
@@ -46,6 +46,7 @@ struct nokia_modem_device {
 	struct nokia_modem_gpio	*gpios;
 	int			gpio_amount;
 	struct hsi_client	*ssi_protocol;
+	struct hsi_client	*cmt_speech;
 };
 
 static void do_nokia_modem_rst_ind_tasklet(unsigned long data)
@@ -149,6 +150,7 @@ static int nokia_modem_probe(struct device *dev)
 	struct hsi_port *port = hsi_get_port(cl);
 	int irq, pflags, err;
 	struct hsi_board_info ssip;
+	struct hsi_board_info cmtspeech;
 
 	np = dev->of_node;
 	if (!np) {
@@ -214,12 +216,35 @@ static int nokia_modem_probe(struct device *dev)
 		goto error3;
 	}
 
-	/* TODO: register cmt-speech hsi client */
+	cmtspeech.name = "cmt-speech";
+	cmtspeech.tx_cfg = cl->tx_cfg;
+	cmtspeech.rx_cfg = cl->rx_cfg;
+	cmtspeech.platform_data = NULL;
+	cmtspeech.archdata = NULL;
+
+	modem->cmt_speech = hsi_new_client(port, &cmtspeech);
+	if (!modem->cmt_speech) {
+		dev_err(dev, "Could not register cmt-speech device\n");
+		err = -ENOMEM;
+		goto error3;
+	}
+
+	err = device_attach(&modem->cmt_speech->device);
+	if (err == 0) {
+		dev_err(dev, "Missing cmt-speech driver\n");
+		err = -EPROBE_DEFER;
+		goto error4;
+	} else if (err < 0) {
+		dev_err(dev, "Could not load cmt-speech driver (%d)\n", err);
+		goto error4;
+	}
 
 	dev_info(dev, "Registered Nokia HSI modem\n");
 
 	return 0;
 
+error4:
+	hsi_remove_client(&modem->cmt_speech->device, NULL);
 error3:
 	hsi_remove_client(&modem->ssi_protocol->device, NULL);
 error2:
@@ -238,6 +263,11 @@ static int nokia_modem_remove(struct device *dev)
 	if (!modem)
 		return 0;
 
+	if (modem->cmt_speech) {
+		hsi_remove_client(&modem->cmt_speech->device, NULL);
+		modem->cmt_speech = NULL;
+	}
+
 	if (modem->ssi_protocol) {
 		hsi_remove_client(&modem->ssi_protocol->device, NULL);
 		modem->ssi_protocol = NULL;
Signature · 1 line
2.1.4
author maintainer
#5 lore raw
In reply to Sebastian Reichel

Hi,

Quoted 1 line · Sebastian Reichel

[1] git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-hsi.git branch/cmt-speech-2

This should actually be:

git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-hsi.git branch/cmt-speech-3

-- Sebastian

author maintainer
#6 lore raw
In reply to Sebastian Reichel

Hi,

Quoted 8 lines · Sebastian Reichel

This patchset contains the missing speech data support for the Nokia N900 modem.

[...]

HSI: cmt_speech: Add cmt-speech driver
HSI: nokia-modem: Add cmt-speech support

Quoted 9 lines
 drivers/hsi/clients/Kconfig          |   12 +-
 drivers/hsi/clients/Makefile         |    1 +
 drivers/hsi/clients/cmt_speech.c     | 1456 ++++++++++++++++++++++++++++++++++
 drivers/hsi/clients/nokia-modem.c    |   32 +-
 include/uapi/linux/hsi/Kbuild        |    2 +-
 include/uapi/linux/hsi/cs-protocol.h |  113 +++
 6 files changed, 1613 insertions(+), 3 deletions(-)
 create mode 100644 drivers/hsi/clients/cmt_speech.c
 create mode 100644 include/uapi/linux/hsi/cs-protocol.h

I added the patches to my linux-hsi.git for-next branch aimed for 4.1.

-- Sebastian