Skip to contentSkip to conversation

input: Add support for ECI (multimedia) accessories

PATCH Superseded [email protected] 2 participants 8 messages Jan 19, 2011 – Jan 20, 2011

Subsystems (2)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v4 cover input: Add support for ECI (multimedia) accessories

From: Tapio Vihuri <[email protected]>

Thank you for comments.

ECI input driver changes:

- Use driver name in debugfs
- reject accessory stating more than maximum 31 buttons
- clean out couple comments

ECI controller driver changes:

- name change, from ecibus to eci_xxx_ctrl
- location change, from drivers/ecibus to drivers/input/misc
- major rework from platform driver to i2c-driver
- removed mrst platform dependency

Checkpatch warn about Kconfig, but I think it is false positive, and I will report it to the maintainer.

Platform code changes:

- medfield_ prefix changed to mrst_
- added ECI controller needed power control
- remover ECI controller platform driver stuff
- added i2c stuff for ECI controller driver

Created against linux-2.6.37-rc8 at:
a25cecc Merge branch 'next' of git://git.monstr.eu/linux-2.6-microblaze

--- v3 message ---

Thank you for comments.

ECI input driver changes:

- Makefile and Kconfig sorted alphabetically
- using sparse keymap library, much cleaner solution
- correct string aligment with 80 column
- debugfs initialization fix
- sysfs cable entry using just 0/1
- using cheaper __set_bit
- insane comments fixed
- remove unneeded misc device

Created against linux-2.6.37-rc8 at:
989d873 Merge master.kernel.org:/home/rmk/linux-2.6-arm

--- v2 message ---

Thank you for comments.

In series two there Kconfig dependency problem fixed, preventing compilation if X86_MRST (Intel Moorestown) or INPUT_MISC is not selected.

Also created against linux-2.6.37-rc8

--- v1 message ---

Hi all

This patch set introduce Multimedia Headset Accessory support for Nokia phones. Technically those are known as ECI (Enhancement Control Interface)

If headset has many buttons, like play, vol+, vol- etc. then it is propably ECI accessory.

Among several buttons ECI accessories contains memory for storing several parameters.

This ECI input driver provides the following features:
- reading ECI configuration memory
- ECI buttons as input events

Drive is constructed as follows:
- ECI accessory input driver deals with headset accessory
- ECI bus control driver deals the HW transfering data to/from headset
- platform data match used HW

In the future accessory detection logic will be added using ALSA jack reporting.

Created against linux-2.6.37-rc6

Please review.

Tapio Vihuri (3):
ECI: input: introduce ECI accessory input driver
ECI: introducing ECI controller driver
ECI: adding platform data for ECI driver

 arch/x86/platform/mrst/mrst.c      |   49 ++
 drivers/input/misc/Kconfig         |   60 +++
 drivers/input/misc/Makefile        |    3 +-
 drivers/input/misc/eci.c           |  946 ++++++++++++++++++++++++++++++++++++
 drivers/input/misc/eci_at20_ctrl.c |  533 ++++++++++++++++++++
 include/linux/input/eci.h          |  179 +++++++
 6 files changed, 1769 insertions(+), 1 deletions(-)
 create mode 100644 drivers/input/misc/eci.c
 create mode 100644 drivers/input/misc/eci_at20_ctrl.c
 create mode 100644 include/linux/input/eci.h
#1 lore raw

PATCH v4 1/3 ECI: input: introduce ECI accessory input driver

From: Tapio Vihuri <[email protected]>

ECI stands for (Enhancement Control Interface).

ECI is better known as Multimedia Headset for Nokia phones.
If headset has many buttons, like play, vol+, vol- etc. then it is propably ECI accessory.
Among several buttons ECI accessory contains memory for storing several parameters.

ECI input driver provides the following features:
- reading ECI configuration memory
- ECI buttons as input events

---
 drivers/input/misc/Kconfig  |   19 +
 drivers/input/misc/Makefile |    2 +-
 drivers/input/misc/eci.c    |  946 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/input/eci.h   |  157 +++++++
 4 files changed, 1123 insertions(+), 1 deletions(-)
 create mode 100644 drivers/input/misc/eci.c
 create mode 100644 include/linux/input/eci.h
drivers/input/misc/Kconfig +19 -0
index b0c6772..56cdc62 100644
@@ -114,6 +114,25 @@ config INPUT_APANEL
 	 To compile this driver as a module, choose M here: the module will
 	 be called apanel.
 
+config INPUT_ECI
+	tristate "AV ECI (Enhancement Control Interface) input driver"
+	select INPUT_SPARSEKMAP
+	help
+	The Enhancement Control Interface functionality
+	  ECI is better known as Multimedia Headset for Nokia phones.
+	  If headset has many buttons, like play, vol+, vol- etc. then
+	  it is propably ECI accessory.
+	  Among several buttons ECI accessory contains memory for storing
+	  several parameters.
+
+	  ECI input driver provides the following features:
+	  - reading ECI configuration memory
+	  - ECI buttons as input events
+
+	  Say 'y' here to statically link this module into the kernel or 'm'
+	  to build it as a dynamically loadable module. The module will be
+	  called eci.ko
+
 config INPUT_IXP4XX_BEEPER
 	tristate "IXP4XX Beeper support"
 	depends on ARCH_IXP4XX
drivers/input/misc/Makefile +1 -1
index 9b47971..fa99597 100644
@@ -23,6 +23,7 @@ obj-$(CONFIG_INPUT_CMA3000_I2C)		+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)		+= cobalt_btns.o
 obj-$(CONFIG_INPUT_DM355EVM)		+= dm355evm_keys.o
 obj-$(CONFIG_HP_SDC_RTC)		+= hp_sdc_rtc.o
+obj-$(CONFIG_INPUT_ECI)			+= eci.o
 obj-$(CONFIG_INPUT_IXP4XX_BEEPER)	+= ixp4xx-beeper.o
 obj-$(CONFIG_INPUT_KEYSPAN_REMOTE)	+= keyspan_remote.o
 obj-$(CONFIG_INPUT_M68K_BEEP)		+= m68kspkr.o
@@ -43,4 +44,3 @@ obj-$(CONFIG_INPUT_UINPUT)		+= uinput.o
 obj-$(CONFIG_INPUT_WISTRON_BTNS)	+= wistron_btns.o
 obj-$(CONFIG_INPUT_WM831X_ON)		+= wm831x-on.o
 obj-$(CONFIG_INPUT_YEALINK)		+= yealink.o
-
drivers/input/misc/eci.c new file +946 -0

946 lines not on this page · raw message

include/linux/input/eci.h new file +157 -0

157 lines not on this page · raw message

Signature · 1 line
1.6.5
#2 lore raw

PATCH v4 2/3 ECI: introducing ECI controller driver

From: Tapio Vihuri <[email protected]>

ECI controller is kind of bridge between host CPU I2C and ECI accessory ECI communication.

---
 drivers/input/misc/Kconfig         |   41 +++
 drivers/input/misc/Makefile        |    1 +
 drivers/input/misc/eci_at20_ctrl.c |  533 ++++++++++++++++++++++++++++++++++++
 include/linux/input/eci.h          |   24 ++-
 4 files changed, 598 insertions(+), 1 deletions(-)
 create mode 100644 drivers/input/misc/eci_at20_ctrl.c
drivers/input/misc/Kconfig +41 -0
index 56cdc62..fa64398 100644
@@ -114,6 +114,23 @@ config INPUT_APANEL
 	 To compile this driver as a module, choose M here: the module will
 	 be called apanel.
 
+menuconfig ECI
+	bool "ECI support"
+	help
+	  ECI (Enhancement Control Interface) accessory support
+
+	  The Enhancement Control Interface functionality
+	  ECI is better known as Multimedia Headset for Nokia phones.
+	  If headset has many buttons, like play, vol+, vol- etc. then
+	  it is propably ECI accessory.
+	  Among several buttons ECI accessory contains memory for storing
+	  several parameters.
+
+	  Enable ECI support in terminal so that ECI input driver is able
+	  to communicate with ECI accessory
+
+if ECI
+
 config INPUT_ECI
 	tristate "AV ECI (Enhancement Control Interface) input driver"
 	select INPUT_SPARSEKMAP
@@ -129,10 +146,34 @@ config INPUT_ECI
 	  - reading ECI configuration memory
 	  - ECI buttons as input events
 
+	  ECI input driver needs some ECI controller driver, select
+	  suitable controlelr driver(s) below.
+
 	  Say 'y' here to statically link this module into the kernel or 'm'
 	  to build it as a dynamically loadable module. The module will be
 	  called eci.ko
 
+config ECI_CTRL_DEBUG
+	bool "ECI controller debug"
+	depends on INPUT_ECI_AT20
+	help
+	  Say Y here to enable debugging messages for ECI controller driver.
+
+config INPUT_ECI_AT20
+	tristate "ECI controller driver"
+	select INPUT_ECI
+	depends on X86_MRST && INPUT_MISC
+	help
+	  This selects a driver for the ECI controller
+
+	  ECI controller is kind of bridge between host CPU I2C and
+	  ECI accessory ECI communication.
+
+	  Say 'y' here to statically link this module into the kernel or 'm'
+	  to build it as a dynamically loadable module. The module will be
+	  called eci_at20_ctrl.ko
+endif # ECI
+
 config INPUT_IXP4XX_BEEPER
 	tristate "IXP4XX Beeper support"
 	depends on ARCH_IXP4XX
drivers/input/misc/Makefile +1 -0
index fa99597..5e3dd7c 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_INPUT_COBALT_BTNS)		+= cobalt_btns.o
 obj-$(CONFIG_INPUT_DM355EVM)		+= dm355evm_keys.o
 obj-$(CONFIG_HP_SDC_RTC)		+= hp_sdc_rtc.o
 obj-$(CONFIG_INPUT_ECI)			+= eci.o
+obj-$(CONFIG_INPUT_ECI_AT20)		+= eci_at20_ctrl.o
 obj-$(CONFIG_INPUT_IXP4XX_BEEPER)	+= ixp4xx-beeper.o
 obj-$(CONFIG_INPUT_KEYSPAN_REMOTE)	+= keyspan_remote.o
 obj-$(CONFIG_INPUT_M68K_BEEP)		+= m68kspkr.o
drivers/input/misc/eci_at20_ctrl.c new file +533 -0

533 lines not on this page · raw message

include/linux/input/eci.h +23 -1
index 0e22404..868d2fb 100644
@@ -1,7 +1,7 @@
 /*
  * This file is part of ECI (Enhancement Control Interface) driver
  *
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
  *
  * Contact: Tapio Vihuri <[email protected]>
  *
@@ -35,6 +35,21 @@
 #define ECI_REAL_BUTTONS	0
 #define ECI_FORCE_BUTTONS_UP	1
 
+/*
+ * VPROG2CNT - VPROG2 Control Register
+ * 2.5V | normal | normal
+ * 10   | 111    | 111
+ * 2.5V | off    | off
+ * 10   | 100    | 100
+ */
+#define AvP_MSIC_VPROG2		0xd7
+#define AvP_MSIC_VPROG2_2V5_ON	0xbf
+#define AvP_MSIC_VPROG2_2V5_OFF 0xa4
+
+#define GPIO_ECI_RSTn		126	/* GP_CORE_030 + 96 */
+#define GPIO_ECI_SW_CTRL	178	/* GP_CORE_082 + 96 */
+#define GPIO_ECI_INT		16	/* GP_AON_016 */
+
 /* fixed in ECI HW, do not change */
 enum {
 	ECICMD_HWID,
@@ -154,4 +169,11 @@ struct eci_data {
 };
 
 struct eci_cb *eci_register(struct eci_hw_ops *eci_ops);
+
+/* eci controller data */
+struct eci_ctrl_platform_data {
+	int		eci_ctrl_rst_gpio;
+	int		eci_ctrl_sw_ctrl_gpio;
+	int		eci_ctrl_int_gpio;
+};
 #endif
Signature · 1 line
1.6.5
#3 lore raw

PATCH v4 3/3 ECI: adding platform data for ECI driver

From: Tapio Vihuri <[email protected]>

Gives platform data for ECI accessory input driver and ECI controller driver.

---
 arch/x86/platform/mrst/mrst.c |   49 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)
arch/x86/platform/mrst/mrst.c +49 -0
index ea6529e..ac2533f 100644
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/irq.h>
 #include <linux/module.h>
+#include <linux/input/eci.h>
 
 #include <asm/setup.h>
 #include <asm/mpspec_def.h>
@@ -478,6 +479,16 @@ static void __init *no_platform_data(void *info)
 	return NULL;
 }
 
+static void *eci_ctrl_platform_data_init(void *info)
+{
+	static struct eci_ctrl_platform_data mrst_eci_ctrl_data = {
+		.eci_ctrl_rst_gpio = GPIO_ECI_RSTn,
+		.eci_ctrl_sw_ctrl_gpio = GPIO_ECI_SW_CTRL,
+		.eci_ctrl_int_gpio = GPIO_ECI_INT,
+	};
+	return &mrst_eci_ctrl_data;
+}
+
 static const struct devs_id __initconst device_ids[] = {
 	{"pmic_gpio", SFI_DEV_TYPE_SPI, 1, &pmic_gpio_platform_data},
 	{"spi_max3111", SFI_DEV_TYPE_SPI, 0, &max3111_platform_data},
@@ -487,6 +498,7 @@ static const struct devs_id __initconst device_ids[] = {
 	{"i2c_accel", SFI_DEV_TYPE_I2C, 0, &lis331dl_platform_data},
 	{"pmic_audio", SFI_DEV_TYPE_IPC, 1, &no_platform_data},
 	{"msic_audio", SFI_DEV_TYPE_IPC, 1, &no_platform_data},
+	{"eci_ctrl", SFI_DEV_TYPE_I2C, 0, &eci_ctrl_platform_data_init},
 	{},
 };
 
@@ -807,3 +819,40 @@ static int __init pb_keys_init(void)
 	return 0;
 }
 late_initcall(pb_keys_init);
+
+/*
+ * This is just example, should be used in platform audio driver
+ * hsmic_event->event(hsmic_event->private, true)
+ */
+static void mrst_register_hsmic_event_cb(struct audio_hsmic_event *event)
+{
+	struct audio_hsmic_event *hsmic_event;
+
+	hsmic_event = event;
+}
+
+static struct eci_platform_data mrst_eci_data = {
+	.register_hsmic_event_cb	= mrst_register_hsmic_event_cb,
+};
+
+static struct platform_device mrst_eci_device = {
+	.name	= "ECI_accessory",
+	.dev	= {
+		.platform_data = &mrst_eci_data,
+	},
+};
+
+static int __init mrst_eci_init(void)
+{
+	int retval;
+
+	retval = platform_device_register(&mrst_eci_device);
+	if (retval < 0)
+		return retval;
+
+	/* Turn on vprog2 */
+	intel_scu_ipc_iowrite8(AvP_MSIC_VPROG2, AvP_MSIC_VPROG2_2V5_ON);
+
+	return retval;
+}
+device_initcall(mrst_eci_init);
Signature · 1 line
1.6.5
maintainer
#4 lore raw

Re: [PATCH v4 1/3] ECI: input: introduce ECI accessory input driver

In reply to [email protected]

Hi Tapio,

drivers/input/misc/eci.c line 576

Quoted 13 lines · On Wed, Jan 19, 2011 at 02:06:54PM +0200, [email protected] wrote:
drivers/input/misc/eci.c new file +13 -0
+
+	for (; key->type != KE_END; key++) {
+		switch (key->type) {
+		case KE_KEY:
+			__set_bit(key->keycode, eci->acc_input->keybit);
+			break;
+		case KE_SW:
+		case KE_VSW:
+			__set_bit(key->keycode, eci->acc_input->swbit);
+			break;
+		}
+	}
+

Is this still needed? I believe sparse_keymap_setup() below shoudl take care of this...

drivers/input/misc/eci.c line 584

Quoted 8 lines
drivers/input/misc/eci.c new file +8 -0
+	__set_bit(EV_KEY, eci->acc_input->evbit);
+	__set_bit(EV_SW, eci->acc_input->evbit);
+	__set_bit(EV_REP, eci->acc_input->evbit);
+
+	err = sparse_keymap_setup(eci->acc_input, eci_keymap, NULL);
+	if (err)
+		goto err_free_dev;
+

Haven't looked at the rest yet...

Thanks.

Signature · 1 line
Dmitry
#5 lore raw

Re: [PATCH v4 1/3] ECI: input: introduce ECI accessory input driver

Quoted 20 lines · ext Dmitry Torokhov

Hi Tapio,

drivers/input/misc/eci.c line 576

Quoted 13 lines · On Wed, Jan 19, 2011 at 02:06:54PM +0200, [email protected] wrote:
drivers/input/misc/eci.c new file +13 -0
+
+	for (; key->type != KE_END; key++) {
+		switch (key->type) {
+		case KE_KEY:
+			__set_bit(key->keycode, eci->acc_input->keybit);
+			break;
+		case KE_SW:
+		case KE_VSW:
+			__set_bit(key->keycode, eci->acc_input->swbit);
+			break;
+		}
+	}
+

Is this still needed? I believe sparse_keymap_setup() below shoudl take care of this...

Quoted 9 lines

drivers/input/misc/eci.c line 584

Quoted 8 lines
drivers/input/misc/eci.c new file +8 -0
+	__set_bit(EV_KEY, eci->acc_input->evbit);
+	__set_bit(EV_SW, eci->acc_input->evbit);
+	__set_bit(EV_REP, eci->acc_input->evbit);
+
+	err = sparse_keymap_setup(eci->acc_input, eci_keymap, NULL);
+	if (err)
+		goto err_free_dev;
+

Hi Dmitry.

Thanks for pointing this out, as we have sparse keymap, we should use it :)

How about KE_VSW case ? Shouldn't it be in the sparse_keymap_setup {} also ?

---------8<------------------------

int sparse_keymap_setup(struct input_dev *dev,
const struct key_entry *keymap, int (*setup)(struct input_dev *, struct
key_entry *))

{
        size_t map_size = 1; /* to account for the last KE_END entry */
        const struct key_entry *e;
        struct key_entry *map, *entry;
        int i;
        int error;

        for (e = keymap; e->type != KE_END; e++)
                map_size++;

        map = kcalloc(map_size, sizeof (struct key_entry), GFP_KERNEL);
        if (!map)
                return -ENOMEM;

        memcpy(map, keymap, map_size * sizeof (struct key_entry));

        for (i = 0; i < map_size; i++) {
                entry = &map[i];

                if (setup) {
                        error = setup(dev, entry);
                        if (error)
                                goto err_out;
                }

                switch (entry->type) {
                case KE_KEY:
                        __set_bit(EV_KEY, dev->evbit);
                        __set_bit(entry->keycode, dev->keybit);
                        break;

                case KE_SW:
                        __set_bit(EV_SW, dev->evbit);
                        __set_bit(entry->sw.code, dev->swbit);
                        break;
                }
        }

        dev->keycode = map;
        dev->keycodemax = map_size;
        dev->getkeycode_new = sparse_keymap_getkeycode;
        dev->setkeycode_new = sparse_keymap_setkeycode;

        return 0;

err_out:

        kfree(map);
        return error;
}

BR,
Tapsa

Signature · 2 lines
Tapsa
050 4876788
maintainer
#6 lore raw

Re: [PATCH v4 1/3] ECI: input: introduce ECI accessory input driver

Quoted 31 lines · Tapio Vihuri
Quoted 20 lines · ext Dmitry Torokhov

Hi Tapio,

Review

Quoted 13 lines · On Wed, Jan 19, 2011 at 02:06:54PM +0200, [email protected] wrote:
(quoted diff) +13 -0
+
+	for (; key->type != KE_END; key++) {
+		switch (key->type) {
+		case KE_KEY:
+			__set_bit(key->keycode, eci->acc_input->keybit);
+			break;
+		case KE_SW:
+		case KE_VSW:
+			__set_bit(key->keycode, eci->acc_input->swbit);
+			break;
+		}
+	}
+

Is this still needed? I believe sparse_keymap_setup() below shoudl take care of this...

Quoted 9 lines

Review

Quoted 8 lines
(quoted diff) +8 -0
+	__set_bit(EV_KEY, eci->acc_input->evbit);
+	__set_bit(EV_SW, eci->acc_input->evbit);
+	__set_bit(EV_REP, eci->acc_input->evbit);
+
+	err = sparse_keymap_setup(eci->acc_input, eci_keymap, NULL);
+	if (err)
+		goto err_free_dev;
+
Quoted 8 lines

Hi Dmitry.

Thanks for pointing this out, as we have sparse keymap, we should use it :)

How about KE_VSW case ? Shouldn't it be in the sparse_keymap_setup {} also ?

Indeed. Does the patch below fix it?

Thanks.

Signature · 14 lines
Dmitry

Input: sparse-keymap - fix KEY_VSW handling in sparse_keymap_setup

From: Dmitry Torokhov <[email protected]>

We were forgetting to set up device capabilities for KEY_VSW entries.

Reported-by: Tapio Vihuri <[email protected]> 
Signed-off-by: Dmitry Torokhov <[email protected]>
---

 drivers/input/sparse-keymap.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/input/sparse-keymap.c +1 -0
index a29a7812..7729e54 100644
@@ -201,6 +201,7 @@ int sparse_keymap_setup(struct input_dev *dev,
 			break;
 
 		case KE_SW:
+		case KE_VSW:
 			__set_bit(EV_SW, dev->evbit);
 			__set_bit(entry->sw.code, dev->swbit);
 			break;
author Tested-by
#7 lore raw

Re: [alsa-devel] [PATCH v4 1/3] ECI: input: introduce ECI accessory input driver

Quoted 7 lines · ext Dmitry Torokhov
Quoted 1 line

How about KE_VSW case ? Shouldn't it be in the sparse_keymap_setup

{}

Quoted 2 lines

also ?

Indeed. Does the patch below fix it?

Hi.

Yes it does, thank you.

Patch working (as it obviously should) OK in my environment, so

Quoted 13 lines

Thanks.

Signature · 10 lines
Dmitry

Input: sparse-keymap - fix KEY_VSW handling in sparse_keymap_setup

From: Dmitry Torokhov <[email protected]>

We were forgetting to set up device capabilities for KEY_VSW entries.

Reported-by: Tapio Vihuri <[email protected]> 
Signed-off-by: Dmitry Torokhov <[email protected]>
Quoted 23 lines

---

 drivers/input/sparse-keymap.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/input/sparse-keymap.c +1 -0
index a29a7812..7729e54 100644
@@ -201,6 +201,7 @@ int sparse_keymap_setup(struct input_dev *dev,
                        break;
 
                case KE_SW:
+               case KE_VSW:
                        __set_bit(EV_SW, dev->evbit);
                        __set_bit(entry->sw.code, dev->swbit);
                        break;

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

Signature · 2 lines
Tapsa
050 4876788