Skip to contentSkip to conversation

hid: new driver for PicoLCD device

PATCH Superseded Bruno Prémont 4 participants 42 messages Mar 24, 2010 – Apr 27, 2010

Subsystems (4)
lore
Share & tools
lore

Bruno Prémont

author maintainer
#0 lore raw

v3 cover hid: new driver for PicoLCD device

This series adds support for PicoLCD USB HID device adding support for the various features in different patches so each patch concentrates on a device class.

Changes since revision 2:
- drop most inline keywords
- use mutex to protect question-wait-for-answer requests
- use mutex to protect flash erase+write+write sequence
- add support for simulated 8-bit mode (advertised grayscale and translated by "pixel & 0x80 ? 1 : 0"
Explaining Jaya's curiosity about my choice, there seem to be (near) no userspace application willing to operate on a 1bpp framebuffer. Simulated 8bpp tested with links (dfbsee has unrelated? issues, fbv seems to always want color map for 8bpp even for grayscale...)
Is it correct to call "8bpp grayscale" TRUECOLOR? If not, what's the right FB_VISUAL_* name?
- fix a couple checkpatch warnings/errors
(there are multiple "longer than 80 char" lines left though
I don't think it's worth/readable to kill them all)
- extract version check into a separate function
- do direct keycode lookup
- replace sysfs_{create,remove}_file with device_{create,remove}_file
- correct initial update of framebuffer

I've not changed the Kconfig part from v2 as an attempt to add sub-options which would select FB, LCD_CLASS, BACKLIGHT_CLASS or LEDS_CLASS ended up in kbuild to complain about a dependency loop for FB.
I'm wondering why I didn't get such a loop for first revision when HID_PICOLCD did select everything...
As this is build-cosmetic it can be looked into at a later time.

The series depends on my previous patch adding HID suspend support
(I've not yet looked at improving it). Except that one the series is
on top of 2.6.34-rc2.
Note that debugfs registration is wrong on hotplug (a fix for this
one is waiting in Jiri's upstream branch:
http://git.kernel.org/?p=linux/kernel/git/jikos/hid.git;a=commitdiff;hMa361b69102cdffe73006771eae7504d2cb8736 )

Bruno

author maintainer
#1 lore raw

PATCH v3 1/6 hid: new driver for PicoLCD device

Add basic driver for PicoLCD graphics device. Initially support keypad with input device and provide support for debugging communication via events file from debugfs.

Changes since v2:
- Move completion to struct picolcd_pending
- Use mutex for commands which generate reply
- Drop inline keyword on non-stub functions
- Combine version check into a common function
- Define PICOLCD_KEYS based on array size
- Lookup keycode directly instead of asking input
- Use device_{create,remove}_file instead of sysfs_{create,remove}_file

---
 Documentation/ABI/testing/sysfs-driver-hid-picolcd |   17 +
 drivers/hid/Kconfig                                |   18 +
 drivers/hid/Makefile                               |    1 +
 drivers/hid/hid-core.c                             |    2 +
 drivers/hid/hid-ids.h                              |    2 +
 drivers/hid/hid-picolcd.c                          | 1213 ++++++++++++++++++++
 6 files changed, 1253 insertions(+), 0 deletions(-)
Documentation/ABI/testing/sysfs-driver-hid-picolcd new file +17 -0
new file mode 100644
index 0000000..1c63a0f
@@ -0,0 +1,17 @@
+What:		/sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/operation_mode
+Date:		March 2010
+Contact:	Bruno Prémont <[email protected]>
+Description:	Make it possible to switch the PicoLCD device between LCD
+		(firmware) and bootloader (flasher) operation modes.
+
+		Reading: returns list of available modes is show, the active mode
+		being enclosed in brackets ('<' and '>')
+
+		Writing: causes operation mode switch. Permitted values are
+		the non-active mode names listed when read, optionally followed
+		by a delay value expressed in ms.
+
+		Note: when switching mode the current PicoLCD HID device gets
+		disconnected and reconnects after above delay (default value
+		is 5 seconds though this default should not be relied on).
+
drivers/hid/Kconfig +18 -0
index 71d4c07..138ba6a 100644
@@ -262,6 +262,24 @@ config HID_PETALYNX
 	---help---
 	Support for Petalynx Maxter remote control.
 
+config HID_PICOLCD
+	tristate "PicoLCD (graphic version)"
+	depends on USB_HID
+	---help---
+	  This provides support for Minibox PicoLCD devices, currently
+	  only the graphical ones are supported.
+
+	  This includes support for the following device features:
+	  - Keypad
+	  - Switching between Firmware and Flash mode
+	  Features that are not (yet) supported:
+	  - Framebuffer for monochrome 256x64 display
+	  - Backlight control
+	  - Contrast control
+	  - IR
+	  - General purpose outputs
+	  - EEProm / Flash access
+
 config HID_QUANTA
 	tristate "Quanta Optical Touch"
 	depends on USB_HID
drivers/hid/Makefile +1 -0
index 0b2618f..7fd1614 100644
@@ -44,6 +44,7 @@ obj-$(CONFIG_HID_ORTEK)		+= hid-ortek.o
 obj-$(CONFIG_HID_QUANTA)	+= hid-quanta.o
 obj-$(CONFIG_HID_PANTHERLORD)	+= hid-pl.o
 obj-$(CONFIG_HID_PETALYNX)	+= hid-petalynx.o
+obj-$(CONFIG_HID_PICOLCD)	+= hid-picolcd.o
 obj-$(CONFIG_HID_SAMSUNG)	+= hid-samsung.o
 obj-$(CONFIG_HID_SMARTJOYPLUS)	+= hid-sjoy.o
 obj-$(CONFIG_HID_SONY)		+= hid-sony.o
drivers/hid/hid-core.c +2 -0
index 2e2aa75..bb11fb4 100644
@@ -1335,6 +1335,8 @@ static const struct hid_device_id hid_blacklist[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) },
drivers/hid/hid-ids.h +2 -0
index 797e064..783b41d 100644
@@ -341,6 +341,8 @@
 #define USB_VENDOR_ID_MICROCHIP		0x04d8
 #define USB_DEVICE_ID_PICKIT1		0x0032
 #define USB_DEVICE_ID_PICKIT2		0x0033
+#define USB_DEVICE_ID_PICOLCD		0xc002
+#define USB_DEVICE_ID_PICOLCD_BOOTLOADER	0xf002
 
 #define USB_VENDOR_ID_MICROSOFT		0x045e
 #define USB_DEVICE_ID_SIDEWINDER_GV	0x003b
drivers/hid/hid-picolcd.c new file +1213 -0

1,213 lines not on this page · raw message

Signature · 1 line
1.6.4.4
#2 lore raw

drivers/hid/hid-picolcd.c line 975

Quoted 2 lines · Bruno Prémont
drivers/hid/hid-picolcd.c new file +2 -0
+	for (i = 0; i < PICOLCD_KEYS; i++) {
+		int key = ((int *)idev->keycode)[i];

Keycodes are now short, not int. Also, just do:

		input_set_capability(idev, EV_KEY, data->keycode[i]);
Quoted 2 lines
drivers/hid/hid-picolcd.c new file +2 -0
+		if (key < KEY_MAX && key >= 0)
+			input_set_capability(idev, EV_KEY, key);
Signature · 1 line
Dmitry
author maintainer
#3 lore raw
Quoted 10 lines · On Thu, 25 March 2010 Dmitry Torokhov <[email protected]> wrote:

drivers/hid/hid-picolcd.c line 975

Quoted 2 lines · Bruno Prémont
drivers/hid/hid-picolcd.c new file +2 -0
+	for (i = 0; i < PICOLCD_KEYS; i++) {
+		int key = ((int *)idev->keycode)[i];

Keycodes are now short, not int. Also, just do:

		input_set_capability(idev, EV_KEY, data->keycode[i]);

drivers/hid/hid-picolcd.c line 977

Quoted 2 lines
drivers/hid/hid-picolcd.c new file +2 -0
+		if (key < KEY_MAX && key >= 0)
+			input_set_capability(idev, EV_KEY, key);

Oops, I was not careful enough when switching over... Thanks for catching,
Bruno

#4 lore raw
Quoted 11 lines · Bruno Prémont
Quoted 9 lines

drivers/hid/hid-picolcd.c line 975

Quoted 2 lines
drivers/hid/hid-picolcd.c new file +2 -0
+	for (i = 0; i < PICOLCD_KEYS; i++) {
+		int key = ((int *)idev->keycode)[i];

Keycodes are now short, not int. Also, just do:

		input_set_capability(idev, EV_KEY, data->keycode[i]);

drivers/hid/hid-picolcd.c line 977

Quoted 2 lines
drivers/hid/hid-picolcd.c new file +2 -0
+		if (key < KEY_MAX && key >= 0)
+			input_set_capability(idev, EV_KEY, key);

Oops, I was not careful enough when switching over...

Dmitry, thanks a lot for rapid review the driver.

Bruno, could you please fix this and submit a followup 1/6 patch, so that I could queue the driver in my tree?

I have almost finished going over the driver and haven't encountered any other issues that would require immediate fixing.

Still, it would be nice to have the framebuffer/LCD/backlight bits reviewed by respective subsystem maintainers. But I'll probably queue the driver nevertheless and add potential ACKs later.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.
#5 lore raw
Quoted 17 lines · Jiri Kosina
Quoted 10 lines · Bruno Prémont
Quoted 8 lines

drivers/hid/hid-picolcd.c line 975

Quoted 2 lines
drivers/hid/hid-picolcd.c new file +2 -0
+	for (i = 0; i < PICOLCD_KEYS; i++) {
+		int key = ((int *)idev->keycode)[i];

Keycodes are now short, not int. Also, just do:

		input_set_capability(idev, EV_KEY, data->keycode[i]);

drivers/hid/hid-picolcd.c line 977

Quoted 2 lines
drivers/hid/hid-picolcd.c new file +2 -0
+		if (key < KEY_MAX && key >= 0)
+			input_set_capability(idev, EV_KEY, key);

Oops, I was not careful enough when switching over...

Dmitry, thanks a lot for rapid review the driver.

Bruno, could you please fix this and submit a followup 1/6 patch, so that I could queue the driver in my tree?

Quoted 6 lines

I have almost finished going over the driver and haven't encountered any other issues that would require immediate fixing.

Still, it would be nice to have the framebuffer/LCD/backlight bits reviewed by respective subsystem maintainers. But I'll probably queue the driver nevertheless and add potential ACKs later.

FWIW I am not entrely happy with the whole send-and_wait implementation - it looks like it is not being called concurrently so we don't need mutex there... I'd do something like:

send_nand_wait() {

	set_bit(WAITING_RESPONSE, data->state);
	prepare message
	send message
	wait_for_event_interruptible_timeout(&data->wait,
					!test_bit(WAITING_RESPONSE, data->state));
	if (!test_bit()) {
		process
		return 0;
	}

	return -ETIME;
}

irq(...) {

	else if (test_bit(WAITING_RESPONSE, data->state)) {
		copy response...
		clear_bit(WAITING_RESPONSE, data->state);	
		wake_up(&data->wait);
	}
}

and not bother with kmallocing pending structure, but it should not stop from merging driver.

Signature · 1 line
Dmitry
author maintainer
#6 lore raw
Quoted 21 lines · On Fri, 26 March 2010 Dmitry Torokhov <[email protected]> wrote:
Quoted 20 lines · Jiri Kosina
Quoted 10 lines · Bruno Prémont
Quoted 8 lines

drivers/hid/hid-picolcd.c line 975

Quoted 2 lines
drivers/hid/hid-picolcd.c new file +2 -0
+	for (i = 0; i < PICOLCD_KEYS; i++) {
+		int key = ((int *)idev->keycode)[i];

Keycodes are now short, not int. Also, just do:

		input_set_capability(idev, EV_KEY, data->keycode[i]);

drivers/hid/hid-picolcd.c line 977

Quoted 2 lines
drivers/hid/hid-picolcd.c new file +2 -0
+		if (key < KEY_MAX && key >= 0)
+			input_set_capability(idev, EV_KEY, key);

Oops, I was not careful enough when switching over...

Dmitry, thanks a lot for rapid review the driver.

Bruno, could you please fix this and submit a followup 1/6 patch, so that I could queue the driver in my tree?

I have almost finished going over the driver and haven't encountered any other issues that would require immediate fixing.

Quoted 7 lines
Quoted 3 lines

Still, it would be nice to have the framebuffer/LCD/backlight bits reviewed by respective subsystem maintainers. But I'll probably queue the driver nevertheless and add potential ACKs later.

FWIW I am not entrely happy with the whole send-and_wait implementation - it looks like it is not being called concurrently so we don't need mutex there... I'd do something like:

It can be called concurrently, not within patch 1/6 but it definitely can once patch 6/6 is applied (concurrent access to debugfs files for EEPROM and/or FLASH).
Even later on when FLASH (and EEPROM) access get moved to a better home concurrent access will still exist.

Quoted 24 lines

send_nand_wait() {

	set_bit(WAITING_RESPONSE, data->state);
	prepare message
	send message
	wait_for_event_interruptible_timeout(&data->wait,
					!test_bit(WAITING_RESPONSE, data->state));
	if (!test_bit()) {
		process
		return 0;
	}

	return -ETIME;
}

irq(...) {

	else if (test_bit(WAITING_RESPONSE, data->state)) {
		copy response...
		clear_bit(WAITING_RESPONSE, data->state);	
		wake_up(&data->wait);
	}
}
Quoted 2 lines

and not bother with kmallocing pending structure, but it should not stop from merging driver.

It might be an option to not allocate the pending structure but as the whole "pending" access is definitely not a hot path (flashing firmware or splash and changing EEPROM values will most probably not be done very often). The only more common use is version check on probe.

So what is more expensive, the used memory or the CPU usage to allocate/release the struct? That probably depends on reader's taste.

Bruno

author maintainer
#7 lore raw

PATCH v4 1/6 hid: new driver for PicoLCD device

In reply to Jiri Kosina

Add basic driver for PicoLCD graphics device. Initially support keypad with input device and provide support for debugging communication via events file from debugfs.

Changes since v3:
- Fix incorrect type change for keycode array
- Correct path in sysfs entry documentation
- Make operation_mode sysfs attr use '[', ']' brackets like PM
Changes since v2:
- Move completion to struct picolcd_pending
- Use mutex for commands which generate reply
- Drop inline keyword on non-stub functions
- Combine version check into a common function
- Define PICOLCD_KEYS based on array size
- Lookup keycode directly instead of asking input
- Use device_{create,remove}_file instead of sysfs_{create,remove}_file

---

Quoted 2 lines · On Fri, 26 March 2010 Jiri Kosina <[email protected]> wrote:

Bruno, could you please fix this and submit a followup 1/6 patch, so that I could queue the driver in my tree?

Here it is (with a few more fixes to input part and minor improvements regarding sysfs attribute).

Note that I also sent an updated 2/6 patch for the framebuffer to improve the sysfs attribute in there and document it.

 Documentation/ABI/testing/sysfs-driver-hid-picolcd |   17 +
 drivers/hid/Kconfig                                |   18 +
 drivers/hid/Makefile                               |    1 +
 drivers/hid/hid-core.c                             |    2 +
 drivers/hid/hid-ids.h                              |    2 +
 drivers/hid/hid-picolcd.c                          | 1210 ++++++++++++++++++++
 6 files changed, 1250 insertions(+), 0 deletions(-)
Documentation/ABI/testing/sysfs-driver-hid-picolcd new file +17 -0
new file mode 100644
index 0000000..6fb4f21
@@ -0,0 +1,17 @@
+What:		/sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/operation_mode
+Date:		March 2010
+Contact:	Bruno Prémont <[email protected]>
+Description:	Make it possible to switch the PicoLCD device between LCD
+		(firmware) and bootloader (flasher) operation modes.
+
+		Reading: returns list of available modes, the active mode being
+		enclosed in brackets ('[' and ']')
+
+		Writing: causes operation mode switch. Permitted values are
+		the non-active mode names listed when read, optionally followed
+		by a delay value expressed in ms.
+
+		Note: when switching mode the current PicoLCD HID device gets
+		disconnected and reconnects after above delay (default value
+		is 5 seconds though this default should not be relied on).
+
drivers/hid/Kconfig +18 -0
index 71d4c07..138ba6a 100644
@@ -262,6 +262,24 @@ config HID_PETALYNX
 	---help---
 	Support for Petalynx Maxter remote control.
 
+config HID_PICOLCD
+	tristate "PicoLCD (graphic version)"
+	depends on USB_HID
+	---help---
+	  This provides support for Minibox PicoLCD devices, currently
+	  only the graphical ones are supported.
+
+	  This includes support for the following device features:
+	  - Keypad
+	  - Switching between Firmware and Flash mode
+	  Features that are not (yet) supported:
+	  - Framebuffer for monochrome 256x64 display
+	  - Backlight control
+	  - Contrast control
+	  - IR
+	  - General purpose outputs
+	  - EEProm / Flash access
+
 config HID_QUANTA
 	tristate "Quanta Optical Touch"
 	depends on USB_HID
drivers/hid/Makefile +1 -0
index 0b2618f..7fd1614 100644
@@ -44,6 +44,7 @@ obj-$(CONFIG_HID_ORTEK)		+= hid-ortek.o
 obj-$(CONFIG_HID_QUANTA)	+= hid-quanta.o
 obj-$(CONFIG_HID_PANTHERLORD)	+= hid-pl.o
 obj-$(CONFIG_HID_PETALYNX)	+= hid-petalynx.o
+obj-$(CONFIG_HID_PICOLCD)	+= hid-picolcd.o
 obj-$(CONFIG_HID_SAMSUNG)	+= hid-samsung.o
 obj-$(CONFIG_HID_SMARTJOYPLUS)	+= hid-sjoy.o
 obj-$(CONFIG_HID_SONY)		+= hid-sony.o
drivers/hid/hid-core.c +2 -0
index 2e2aa75..bb11fb4 100644
@@ -1335,6 +1335,8 @@ static const struct hid_device_id hid_blacklist[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) },
drivers/hid/hid-ids.h +2 -0
index 797e064..783b41d 100644
@@ -341,6 +341,8 @@
 #define USB_VENDOR_ID_MICROCHIP		0x04d8
 #define USB_DEVICE_ID_PICKIT1		0x0032
 #define USB_DEVICE_ID_PICKIT2		0x0033
+#define USB_DEVICE_ID_PICOLCD		0xc002
+#define USB_DEVICE_ID_PICOLCD_BOOTLOADER	0xf002
 
 #define USB_VENDOR_ID_MICROSOFT		0x045e
 #define USB_DEVICE_ID_SIDEWINDER_GV	0x003b
drivers/hid/hid-picolcd.c new file +1210 -0

1,210 lines not on this page · raw message

Signature · 1 line
1.6.4.4
#8 lore raw
Quoted 21 lines · Bruno Prémont
drivers/hid/hid-picolcd.c new file +21 -0
+#ifdef CONFIG_PM
+static int picolcd_suspend(struct hid_device *hdev)
+{
+	dbg_hid(PICOLCD_NAME " device ready for suspend\n");
+	return 0;
+}
+
+static int picolcd_resume(struct hid_device *hdev)
+{
+	return 0;
+}
+
+static int picolcd_reset_resume(struct hid_device *hdev)
+{
+	int ret;
+	ret = picolcd_reset(hdev);
+	if (ret)
+		dbg_hid(PICOLCD_NAME " resetting our device failed: %d\n", ret);
+	return 0;
+}
+#endif

[ ... ]

drivers/hid/hid-picolcd.c line 1195

Quoted 12 lines
drivers/hid/hid-picolcd.c new file +12 -0
+static struct hid_driver picolcd_driver = {
+	.name =          "hid-picolcd",
+	.id_table =      picolcd_devices,
+	.probe =         picolcd_probe,
+	.remove =        picolcd_remove,
+	.raw_event =     picolcd_raw_event,
+#ifdef CONFIG_PM
+	.suspend =       picolcd_suspend,
+	.resume =        picolcd_resume,
+	.reset_resume =  picolcd_reset_resume,
+#endif
+};

struct hid_driver doesn't provide power-management related callbacks. So I guess that you have either not tested this feature at all, or you have some extra patch somewhere which adds such callbacks to HID core, but you haven't sent it out for review?

In any cases, this will very likely cause compilation failure with CONFIG_PM turned on.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.
author maintainer
#9 lore raw
Quoted 42 lines · On Mon, 29 Mar 2010 11:47:27 +0200 Jiri Kosina <[email protected]> wrote:
Quoted 21 lines · Bruno Prémont
drivers/hid/hid-picolcd.c new file +21 -0
+#ifdef CONFIG_PM
+static int picolcd_suspend(struct hid_device *hdev)
+{
+	dbg_hid(PICOLCD_NAME " device ready for suspend\n");
+	return 0;
+}
+
+static int picolcd_resume(struct hid_device *hdev)
+{
+	return 0;
+}
+
+static int picolcd_reset_resume(struct hid_device *hdev)
+{
+	int ret;
+	ret = picolcd_reset(hdev);
+	if (ret)
+		dbg_hid(PICOLCD_NAME " resetting our device failed: %d\n", ret);
+	return 0;
+}
+#endif

[ ... ]

drivers/hid/hid-picolcd.c line 1195

Quoted 12 lines
drivers/hid/hid-picolcd.c new file +12 -0
+static struct hid_driver picolcd_driver = {
+	.name =          "hid-picolcd",
+	.id_table =      picolcd_devices,
+	.probe =         picolcd_probe,
+	.remove =        picolcd_remove,
+	.raw_event =     picolcd_raw_event,
+#ifdef CONFIG_PM
+	.suspend =       picolcd_suspend,
+	.resume =        picolcd_resume,
+	.reset_resume =  picolcd_reset_resume,
+#endif
+};

struct hid_driver doesn't provide power-management related callbacks. So I guess that you have either not tested this feature at all, or you have some extra patch somewhere which adds such callbacks to HID core, but you haven't sent it out for review?

Quoted 2 lines

In any cases, this will very likely cause compilation failure with CONFIG_PM turned on.

That's the patch I referred to (under series introduction mail) when saying:

Quoted 2 lines

The series depends on my previous patch adding HID suspend support (I've not yet looked at improving it).

Link to the patch:
http://lkml.org/lkml/2010/2/24/233

Especially the reset-resume part is important as the device has to be reprogrammed with framebuffer content, brightness/contrast in that case.

As stated, Oliver didn't like the implementation of the addition of those hooks too much and I have yet to look at improving it.

Thanks,
Bruno

#10 lore raw
Quoted 26 lines · Bruno Prémont
Quoted 18 lines

drivers/hid/hid-picolcd.c line 1195

Quoted 12 lines
drivers/hid/hid-picolcd.c new file +12 -0
+static struct hid_driver picolcd_driver = {
+	.name =          "hid-picolcd",
+	.id_table =      picolcd_devices,
+	.probe =         picolcd_probe,
+	.remove =        picolcd_remove,
+	.raw_event =     picolcd_raw_event,
+#ifdef CONFIG_PM
+	.suspend =       picolcd_suspend,
+	.resume =        picolcd_resume,
+	.reset_resume =  picolcd_reset_resume,
+#endif
+};

struct hid_driver doesn't provide power-management related callbacks. So I guess that you have either not tested this feature at all, or you have some extra patch somewhere which adds such callbacks to HID core, but you haven't sent it out for review?

Quoted 2 lines

In any cases, this will very likely cause compilation failure with CONFIG_PM turned on.

That's the patch I referred to (under series introduction mail) when saying:

Quoted 2 lines

The series depends on my previous patch adding HID suspend support (I've not yet looked at improving it).

Quoted 8 lines

Link to the patch:
http://lkml.org/lkml/2010/2/24/233

Especially the reset-resume part is important as the device has to be reprogrammed with framebuffer content, brightness/contrast in that case.

As stated, Oliver didn't like the implementation of the addition of those hooks too much and I have yet to look at improving it.

Ah, OK, I have missed that one, thanks for pointing it out.

The driver itself now looks fine to me and I am willing to merge it, modulo the power-management code -- so please either remove the parts that depend on power management for now, or I'll wait on your respin of the generic HID-PM patch.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.
author maintainer
#11 lore raw

v6 cover hid: new driver for PicoLCD device

Quoted 2 lines · On Tue, 30 March 2010 Jiri Kosina <[email protected]> wrote:

so please either remove the parts that depend on power management for now, or I'll wait on your respin of the generic HID-PM patch.

Here I respin the whole series, with PM moved to patch n°8 and patch n°7 being my original generic HID-PM.
Without the PM part there is one compiler warning about defined but unused function (picolcd_resume_backlight), I hope this is not an issue. If it is that function can move over to the PM patch (with it's stub for !CONFIG_BACKLIGHT_CLASS_DEVICE case)

So for now you can skip the last two patches during merge.

Do you have any suggestions regarding generic HID-PM as to how much and how it should be visible to the HID driver?

Thanks,
Bruno

author maintainer
#12 lore raw

PATCH v6 1/8 hid: new driver for PicoLCD device

Add basic driver for PicoLCD graphics device. Initially support keypad with input device and provide support for debugging communication via events file from debugfs.

Changes since v4:
- Moved PM support to separate patch
Changes since v3:
- Fix incorrect type change for keycode array
- Correct path in sysfs entry documentation
- Make operation_mode sysfs attr use '[', ']' brackets like PM
Changes since v2:
- Move completion to struct picolcd_pending
- Use mutex for commands which generate reply
- Drop inline keyword on non-stub functions
- Combine version check into a common function
- Define PICOLCD_KEYS based on array size
- Lookup keycode directly instead of asking input
- Use device_{create,remove}_file instead of sysfs_{create,remove}_file

---
 Documentation/ABI/testing/sysfs-driver-hid-picolcd |   17 +
 drivers/hid/Kconfig                                |   18 +
 drivers/hid/Makefile                               |    1 +
 drivers/hid/hid-core.c                             |    2 +
 drivers/hid/hid-ids.h                              |    2 +
 drivers/hid/hid-picolcd.c                          | 1183 ++++++++++++++++++++
 6 files changed, 1223 insertions(+), 0 deletions(-)
Documentation/ABI/testing/sysfs-driver-hid-picolcd new file +17 -0
new file mode 100644
index 0000000..6fb4f21
@@ -0,0 +1,17 @@
+What:		/sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/operation_mode
+Date:		March 2010
+Contact:	Bruno Prémont <[email protected]>
+Description:	Make it possible to switch the PicoLCD device between LCD
+		(firmware) and bootloader (flasher) operation modes.
+
+		Reading: returns list of available modes, the active mode being
+		enclosed in brackets ('[' and ']')
+
+		Writing: causes operation mode switch. Permitted values are
+		the non-active mode names listed when read, optionally followed
+		by a delay value expressed in ms.
+
+		Note: when switching mode the current PicoLCD HID device gets
+		disconnected and reconnects after above delay (default value
+		is 5 seconds though this default should not be relied on).
+
drivers/hid/Kconfig +18 -0
index 71d4c07..138ba6a 100644
@@ -262,6 +262,24 @@ config HID_PETALYNX
 	---help---
 	Support for Petalynx Maxter remote control.
 
+config HID_PICOLCD
+	tristate "PicoLCD (graphic version)"
+	depends on USB_HID
+	---help---
+	  This provides support for Minibox PicoLCD devices, currently
+	  only the graphical ones are supported.
+
+	  This includes support for the following device features:
+	  - Keypad
+	  - Switching between Firmware and Flash mode
+	  Features that are not (yet) supported:
+	  - Framebuffer for monochrome 256x64 display
+	  - Backlight control
+	  - Contrast control
+	  - IR
+	  - General purpose outputs
+	  - EEProm / Flash access
+
 config HID_QUANTA
 	tristate "Quanta Optical Touch"
 	depends on USB_HID
drivers/hid/Makefile +1 -0
index 0b2618f..7fd1614 100644
@@ -44,6 +44,7 @@ obj-$(CONFIG_HID_ORTEK)		+= hid-ortek.o
 obj-$(CONFIG_HID_QUANTA)	+= hid-quanta.o
 obj-$(CONFIG_HID_PANTHERLORD)	+= hid-pl.o
 obj-$(CONFIG_HID_PETALYNX)	+= hid-petalynx.o
+obj-$(CONFIG_HID_PICOLCD)	+= hid-picolcd.o
 obj-$(CONFIG_HID_SAMSUNG)	+= hid-samsung.o
 obj-$(CONFIG_HID_SMARTJOYPLUS)	+= hid-sjoy.o
 obj-$(CONFIG_HID_SONY)		+= hid-sony.o
drivers/hid/hid-core.c +2 -0
index 2e2aa75..bb11fb4 100644
@@ -1335,6 +1335,8 @@ static const struct hid_device_id hid_blacklist[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) },
drivers/hid/hid-ids.h +2 -0
index 797e064..783b41d 100644
@@ -341,6 +341,8 @@
 #define USB_VENDOR_ID_MICROCHIP		0x04d8
 #define USB_DEVICE_ID_PICKIT1		0x0032
 #define USB_DEVICE_ID_PICKIT2		0x0033
+#define USB_DEVICE_ID_PICOLCD		0xc002
+#define USB_DEVICE_ID_PICOLCD_BOOTLOADER	0xf002
 
 #define USB_VENDOR_ID_MICROSOFT		0x045e
 #define USB_DEVICE_ID_SIDEWINDER_GV	0x003b
drivers/hid/hid-picolcd.c new file +1183 -0

1,183 lines not on this page · raw message

Signature · 1 line
1.6.4.4
#13 lore raw

Am Dienstag, 30. März 2010 22:33:50 schrieb Bruno Prémont:

Quoted 39 lines
drivers/hid/hid-picolcd.c new file +39 -0
+static ssize_t picolcd_operation_mode_store(struct device *dev,
+               struct device_attribute *attr, const char *buf, size_t count)
+{
+       struct picolcd_data *data = dev_get_drvdata(dev);
+       struct hid_report *report = NULL;
+       size_t cnt = count;
+       int timeout = 5000;
+       unsigned u;
+       unsigned long flags;
+
+       if (cnt >= 3 && strncmp("lcd", buf, 3) = 0) {
+               if (data->status & PICOLCD_BOOTLOADER)
+                       report = picolcd_out_report(REPORT_EXIT_FLASHER, data->hdev);
+               buf += 3;
+               cnt -= 3;
+       } else if (cnt >= 10 && strncmp("bootloader", buf, 10) = 0) {
+               if (!(data->status & PICOLCD_BOOTLOADER))
+                       report = picolcd_out_report(REPORT_EXIT_KEYBOARD, data->hdev);
+               buf += 10;
+               cnt -= 10;
+       }
+       if (!report)
+               return -EINVAL;
+
+       while (cnt > 0 && (*buf = ' ' || *buf = '\t')) {
+               buf++;
+               cnt--;
+       }
+       while (cnt > 0 && (buf[cnt-1] = '\n' || buf[cnt-1] = '\r'))
+               cnt--;
+       if (cnt > 0) {
+               if (sscanf(buf, "%u", &u) != 1)
+                       return -EINVAL;
+               if (u > 30000)
+                       return -EINVAL;
+               else
+                       timeout = u;
+       }
+

drivers/hid/hid-picolcd.c line 395

Quoted 10 lines
drivers/hid/hid-picolcd.c new file +10 -0
+       spin_lock_irqsave(&data->lock, flags);
+       hid_set_field(report->field[0], 0, timeout & 0xff);
+       hid_set_field(report->field[0], 1, (timeout >> 8) & 0xff);
+       usbhid_submit_report(data->hdev, report, USB_DIR_OUT);
+       spin_unlock_irqrestore(&data->lock, flags);
+       return count;
+}
+
+static DEVICE_ATTR(operation_mode, 0644, picolcd_operation_mode_show,
+               picolcd_operation_mode_store);

This violates the one file = one attribute rule.
Can you change this interface?

Regards
Oliver

author maintainer
#14 lore raw

PATCH 1/1 hid: split picolcd's operation_mode sysfs attribute

Original operation_mode sysfs attribute accepts the operation mode as main value with an option delay as second value to change the start-up delay on mode change.

As it is preferred to have exactly one value per sysfs attribute, extract this delay into a separate sysfs attribute called operation_mode_delay.

---
 Documentation/ABI/testing/sysfs-driver-hid-picolcd |   17 ++++-
 drivers/hid/hid-picolcd.c                          |   62 ++++++++++++++-----
 2 files changed, 58 insertions(+), 21 deletions(-)
Documentation/ABI/testing/sysfs-driver-hid-picolcd +13 -4
index 14f52d7..08579e7 100644
@@ -8,12 +8,21 @@ Description:	Make it possible to switch the PicoLCD device between LCD
 		enclosed in brackets ('[' and ']')
 
 		Writing: causes operation mode switch. Permitted values are
-		the non-active mode names listed when read, optionally followed
-		by a delay value expressed in ms.
+		the non-active mode names listed when read.
 
 		Note: when switching mode the current PicoLCD HID device gets
-		disconnected and reconnects after above delay (default value
-		is 5 seconds though this default should not be relied on).
+		disconnected and reconnects after above delay (see attribute
+		operation_mode_delay for its value).
+
+
+What:		/sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/operation_mode_delay
+Date:		April 2010
+Contact:	Bruno Prémont <[email protected]>
+Description:	Delay PicoLCD waits before restarting in new mode when
+		operation_mode has changed.
+
+		Reading/Writing: It is expressed in ms and permitted range is
+		0..30000ms.
 
 
 What:		/sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/fb_update_rate
drivers/hid/hid-picolcd.c +45 -17

121 lines not on this page · raw message

Signature · 1 line
1.6.4.4
#15 lore raw

Re: [PATCH] hid: split picolcd's operation_mode sysfs attribute

Quoted 7 lines · Bruno Prémont

Original operation_mode sysfs attribute accepts the operation mode as main value with an option delay as second value to change the start-up delay on mode change.

As it is preferred to have exactly one value per sysfs attribute, extract this delay into a separate sysfs attribute called operation_mode_delay.

Yeah, thanks for fixing this. Applied.

Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.
author maintainer
#16 lore raw

PATCH v6 2/8 hid: add framebuffer support to PicoLCD device

In reply to Bruno Prémont

Add framebuffer support to PicoLCD device with use of deferred-io.

Only changed areas of framebuffer get sent to device in order to save USB bandwidth and especially resources on PicoLCD device or allow higher refresh rate for a small area. Changed tiles are determined while updating shadow framebuffer.

Changes since v5:
- Moved PM support to separate patch
Changes since v4:
- make backbuffer inconsistent with framebuffer to force refresh in picolcd_fb_reset (e.g. for reset_resume)
- force fb_update() wait for urbs to get out of the queue when it sends more than 1/2 queue worth as a full display refresh fills the whole queue eventually causing queue overrun (and lost report) on a quick system
Changes since v3:
- document fb_update_rate sysfs attribute
- change fb_update_rate read behavior to match enum with selected in brackets presentation
Changes since v2:
- add 8bit grayscale depth as near to no userspace app handles 1bit
- properly send whole framebuffer on reset/init
- drop inline keywords from non-stub functions
- use device_{create,remove}_file instead of sysfs_{create,remove}_file

---
 Documentation/ABI/testing/sysfs-driver-hid-picolcd |   17 +
 drivers/hid/Kconfig                                |    7 +-
 drivers/hid/hid-picolcd.c                          |  567 +++++++++++++++++++-
 drivers/hid/usbhid/hid-core.c                      |    1 +
 4 files changed, 590 insertions(+), 2 deletions(-)
Documentation/ABI/testing/sysfs-driver-hid-picolcd +17 -0
index 6fb4f21..14f52d7 100644
@@ -15,3 +15,20 @@ Description:	Make it possible to switch the PicoLCD device between LCD
 		disconnected and reconnects after above delay (default value
 		is 5 seconds though this default should not be relied on).
 
+
+What:		/sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/fb_update_rate
+Date:		March 2010
+Contact:	Bruno Prémont <[email protected]>
+Description:	Make it possible to adjust defio refresh rate.
+
+		Reading: returns list of available refresh rates (expressed in Hz),
+		the active refresh rate being enclosed in brackets ('[' and ']')
+
+		Writing: accepts new refresh rate expressed in integer Hz
+		within permitted rates.
+
+		Note: As device can barely do 2 complete refreshes a second
+		it only makes sense to adjust this value if only one or two
+		tiles get changed and it's not appropriate to expect the application
+		to flush it's tiny changes explicitely at higher than default rate.
+
drivers/hid/Kconfig +6 -1
index 138ba6a..a813ea9 100644
@@ -265,6 +265,11 @@ config HID_PETALYNX
 config HID_PICOLCD
 	tristate "PicoLCD (graphic version)"
 	depends on USB_HID
+	select FB_DEFERRED_IO if FB
+	select FB_SYS_FILLRECT if FB
+	select FB_SYS_COPYAREA if FB
+	select FB_SYS_IMAGEBLIT if FB
+	select FB_SYS_FOPS if FB
 	---help---
 	  This provides support for Minibox PicoLCD devices, currently
 	  only the graphical ones are supported.
@@ -272,8 +277,8 @@ config HID_PICOLCD
 	  This includes support for the following device features:
 	  - Keypad
 	  - Switching between Firmware and Flash mode
-	  Features that are not (yet) supported:
 	  - Framebuffer for monochrome 256x64 display
+	  Features that are not (yet) supported:
 	  - Backlight control
 	  - Contrast control
 	  - IR
drivers/hid/hid-picolcd.c +566 -1

627 lines not on this page · raw message

drivers/hid/usbhid/hid-core.c +1 -0
index 56d06cd..3e7909b 100644
@@ -623,6 +623,7 @@ int usbhid_wait_io(struct hid_device *hid)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(usbhid_wait_io);
 
 static int hid_set_idle(struct usb_device *dev, int ifnum, int report, int idle)
 {
Signature · 1 line
1.6.4.4
author maintainer
#17 lore raw

PATCH v6 3/8 hid: add backlight support to PicoLCD device

In reply to Bruno Prémont

Add backlight support to PicoLCD device.

Backlight support depends on backlight class and is only being compiled if backlight class has been selected.

Changes since v3:
- Moved PM support to separate patch
Changes since v2:
- Drop inline keyword on non-stub functions

---
 drivers/hid/Kconfig       |    2 +-
 drivers/hid/hid-picolcd.c |  128 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 128 insertions(+), 2 deletions(-)
drivers/hid/Kconfig +1 -1
index a813ea9..588b9ac 100644
@@ -278,8 +278,8 @@ config HID_PICOLCD
 	  - Keypad
 	  - Switching between Firmware and Flash mode
 	  - Framebuffer for monochrome 256x64 display
+	  - Backlight control    (needs CONFIG_BACKLIGHT_CLASS_DEVICE)
 	  Features that are not (yet) supported:
-	  - Backlight control
 	  - Contrast control
 	  - IR
 	  - General purpose outputs
drivers/hid/hid-picolcd.c +127 -1

178 lines not on this page · raw message

Signature · 1 line
1.6.4.4
author maintainer
#18 lore raw

PATCH v6 4/8 hid: add lcd support to PicoLCD device

In reply to Bruno Prémont

Add lcd support to PicoLCD device.

LCD support depends on lcd class and is only being compiled if lcd class has been selected.

Changes since v3:
- Moved PM support to separate patch
Changes since v2:
- Drop inline keyword on non-stub functions

---
 drivers/hid/Kconfig       |    2 +-
 drivers/hid/hid-picolcd.c |  106 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 107 insertions(+), 1 deletions(-)
drivers/hid/Kconfig +1 -1
index 588b9ac..399edc5 100644
@@ -279,8 +279,8 @@ config HID_PICOLCD
 	  - Switching between Firmware and Flash mode
 	  - Framebuffer for monochrome 256x64 display
 	  - Backlight control    (needs CONFIG_BACKLIGHT_CLASS_DEVICE)
+	  - Contrast control     (needs CONFIG_LCD_CLASS_DEVICE)
 	  Features that are not (yet) supported:
-	  - Contrast control
 	  - IR
 	  - General purpose outputs
 	  - EEProm / Flash access
drivers/hid/hid-picolcd.c +106 -0

148 lines not on this page · raw message

Signature · 1 line
1.6.4.4
author maintainer
#19 lore raw

PATCH v6 5/8 hid: add GPO (leds) support to PicoLCD device

In reply to Bruno Prémont

Add leds support to PicoLCD device to drive the GPO pins.

GPO support depends on leds class and is only being compiled if leds class has been selected.

Changes since v3:
- Moved PM support to separate patch
Changes since v2:
- Drop inline keyword on non-stub functions

---
 drivers/hid/Kconfig       |    6 +-
 drivers/hid/hid-picolcd.c |  163 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 166 insertions(+), 3 deletions(-)
drivers/hid/Kconfig +3 -3
index 399edc5..34f6593 100644
@@ -278,11 +278,11 @@ config HID_PICOLCD
 	  - Keypad
 	  - Switching between Firmware and Flash mode
 	  - Framebuffer for monochrome 256x64 display
-	  - Backlight control    (needs CONFIG_BACKLIGHT_CLASS_DEVICE)
-	  - Contrast control     (needs CONFIG_LCD_CLASS_DEVICE)
+	  - Backlight control         (needs CONFIG_BACKLIGHT_CLASS_DEVICE)
+	  - Contrast control          (needs CONFIG_LCD_CLASS_DEVICE)
+	  - General purpose outputs   (needs CONFIG_LEDS_CLASS)
 	  Features that are not (yet) supported:
 	  - IR
-	  - General purpose outputs
 	  - EEProm / Flash access
 
 config HID_QUANTA
drivers/hid/hid-picolcd.c +163 -0

205 lines not on this page · raw message

Signature · 1 line
1.6.4.4
author maintainer
#20 lore raw

PATCH v6 6/8 hid: add experimental access to PicoLCD device's EEPROM and FLASH

In reply to Bruno Prémont

The PicoLCD device has a small amount of EEPROM and also provides access to its FLASH where firmware and splash image are saved.
In flasher mode FLASH access is the only active feature.

Give read/write access to both via debugfs files.

NOTE: EEPROM and FLASH access should be switched to better suited API,
until then the will reside in debugfs

Changes since v3:
- Fix return value of picolcd_debug_reset_open
Changes since v2:
- Drop inline keyword on non-stub functions
- Prevent interleaved flash writes via mutex
- Add description of flash/eeprom access schematincs

---
 drivers/hid/Kconfig       |    2 +-
 drivers/hid/hid-picolcd.c |  439 +++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 423 insertions(+), 18 deletions(-)
drivers/hid/Kconfig +1 -1
index 34f6593..a2ecd83 100644
@@ -281,9 +281,9 @@ config HID_PICOLCD
 	  - Backlight control         (needs CONFIG_BACKLIGHT_CLASS_DEVICE)
 	  - Contrast control          (needs CONFIG_LCD_CLASS_DEVICE)
 	  - General purpose outputs   (needs CONFIG_LEDS_CLASS)
+	  - EEProm / Flash access     (via debugfs)
 	  Features that are not (yet) supported:
 	  - IR
-	  - EEProm / Flash access
 
 config HID_QUANTA
 	tristate "Quanta Optical Touch"
drivers/hid/hid-picolcd.c +422 -17

489 lines not on this page · raw message

Signature · 1 line
1.6.4.4
author maintainer
#21 lore raw

PATCH v6 7/8 hid: add suspend/resume hooks for hid drivers

In reply to Bruno Prémont

Add suspend/resume hooks for HID drivers so these can do some additional state adjustment when device gets suspended/resumed.

This patch calls these hooks from usbhid suspend/resume functions, only calling suspend on plain suspend, not autosuspend. (it might be worth adding an autosuspend parameter to suspend hook and calling suspend in both cases)

---

Note:
this patch needs improvements as mentionned by Olivier Neukum:
- suspend hook for both system suspend and autosuspend
- no call of hook on USB-HID-resume failure

 drivers/hid/usbhid/hid-core.c |   19 ++++++++++++++++++-
 include/linux/hid.h           |    8 ++++++++
 2 files changed, 26 insertions(+), 1 deletions(-)
drivers/hid/usbhid/hid-core.c +18 -1
index 3e7909b..9acf573 100644
@@ -1298,6 +1298,11 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
 		}
 
 	} else {
+		if (hid->driver && hid->driver->suspend) {
+			status = hid->driver->suspend(hid);
+			if (status < 0)
+				return status;
+		}
 		spin_lock_irq(&usbhid->lock);
 		set_bit(HID_REPORTED_IDLE, &usbhid->iofl);
 		spin_unlock_irq(&usbhid->lock);
@@ -1352,6 +1357,11 @@ static int hid_resume(struct usb_interface *intf)
 		hid_io_error(hid);
 	usbhid_restart_queues(usbhid);
 
+	if (hid->driver && hid->driver->resume) {
+		int ret = hid->driver->resume(hid);
+		if (ret < 0 && status = 0)
+			status = ret;
+	}
 	dev_dbg(&intf->dev, "resume status %d\n", status);
 	return 0;
 }
@@ -1360,9 +1370,16 @@ static int hid_reset_resume(struct usb_interface *intf)
 {
 	struct hid_device *hid = usb_get_intfdata(intf);
 	struct usbhid_device *usbhid = hid->driver_data;
+	int status;
 
 	clear_bit(HID_REPORTED_IDLE, &usbhid->iofl);
-	return hid_post_reset(intf);
+	status = hid_post_reset(intf);
+	if (hid->driver && hid->driver->reset_resume) {
+		int ret = hid->driver->reset_resume(hid);
+		if (ret < 0 && status = 0)
+			status = ret;
+	}
+	return status;
 }
 
 #endif /* CONFIG_PM */
include/linux/hid.h +8 -0
index b1344ec..fcf3e5c 100644
@@ -589,6 +589,9 @@ struct hid_usage_id {
  * @report_fixup: called before report descriptor parsing (NULL means nop)
  * @input_mapping: invoked on input registering before mapping an usage
  * @input_mapped: invoked on input registering after mapping an usage
+ * @suspend: invoked on suspend (NULL means nop)
+ * @resume: invoked on resume if device was not reset (NULL means nop)
+ * @reset_resume: invoked on resume if device was reset (NULL means nop)
  *
  * raw_event and event should return 0 on no action performed, 1 when no
  * further processing should be done and negative on error
@@ -629,6 +632,11 @@ struct hid_driver {
 	int (*input_mapped)(struct hid_device *hdev,
 			struct hid_input *hidinput, struct hid_field *field,
 			struct hid_usage *usage, unsigned long **bit, int *max);
+#ifdef CONFIG_PM
+	int (*suspend)(struct hid_device *hdev);
+	int (*resume)(struct hid_device *hdev);
+	int (*reset_resume)(struct hid_device *hdev);
+#endif
 /* private: */
 	struct device_driver driver;
 };
Signature · 1 line
1.6.4.4
#22 lore raw

Re: [PATCH v6 7/8, needs improvement] hid: add suspend/resume hooks for hid drivers

Quoted 8 lines · Bruno Prémont

Add suspend/resume hooks for HID drivers so these can do some additional state adjustment when device gets suspended/resumed.

This patch calls these hooks from usbhid suspend/resume functions, only calling suspend on plain suspend, not autosuspend. (it might be worth adding an autosuspend parameter to suspend hook and calling suspend in both cases)

Quoted 7 lines

---

Note:
this patch needs improvements as mentionned by Olivier Neukum:
- suspend hook for both system suspend and autosuspend
- no call of hook on USB-HID-resume failure

I agree with Oliver's comments.

We should also consider putting the hook calls into bluetooth implementation as well (though there is currently no driver using it, but I don't know, maybe Wacom could benefit from it as well).

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.
author maintainer
#23 lore raw

Re: [PATCH v6 7/8, needs improvement] hid: add suspend/resume hooks for hid drivers

Quoted 18 lines · On Wed, 31 March 2010 Jiri Kosina <[email protected]> wrote:
Quoted 8 lines · Bruno Prémont

Add suspend/resume hooks for HID drivers so these can do some additional state adjustment when device gets suspended/resumed.

This patch calls these hooks from usbhid suspend/resume functions, only calling suspend on plain suspend, not autosuspend. (it might be worth adding an autosuspend parameter to suspend hook and calling suspend in both cases)

Quoted 7 lines

---

Note:
this patch needs improvements as mentionned by Olivier Neukum:
- suspend hook for both system suspend and autosuspend
- no call of hook on USB-HID-resume failure

Quoted 5 lines

I agree with Oliver's comments.

We should also consider putting the hook calls into bluetooth implementation as well (though there is currently no driver using it, but I don't know, maybe Wacom could benefit from it as well).

Where do I find the bluetooth HID bits? I've been searching through kernel sources (under drivers/) but did not find bluetooth code trying to register a HID device...

Below an updated patch which also calls the hook for auto-suspend case. The patch compiles but I've not runtime-tested it yet (especially for the auto-suspend part, as I'm not sure what should trigger it).

As far as I understand the code, in auto-suspend case if the driver sends commands to the device it will have to call usbhid_wait_io(). Please correct me if I'm wrong!

Thanks,
Bruno

---

Add suspend/resume hooks for HID drivers so these can do some additional state adjustment when device gets suspended/resumed.

v2:
- Adds auto_suspend parameter to suspend hook
- Only calls HID driver's resume hooks when previous code did succeed

---
 drivers/hid/usbhid/hid-core.c |   24 +++++++++++++++++++++++-
 include/linux/hid.h           |    8 ++++++++
 2 files changed, 31 insertions(+), 1 deletions(-)
drivers/hid/usbhid/hid-core.c +23 -1
index 3e7909b..1f40695 100644
@@ -1291,6 +1291,11 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
 		{
 			set_bit(HID_REPORTED_IDLE, &usbhid->iofl);
 			spin_unlock_irq(&usbhid->lock);
+			if (hid->driver && hid->driver->suspend) {
+				status = hid->driver->suspend(hid, 1);
+				if (status < 0)
+					return status;
+			}
 		} else {
 			usbhid_mark_busy(usbhid);
 			spin_unlock_irq(&usbhid->lock);
@@ -1298,6 +1303,11 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
 		}
 
 	} else {
+		if (hid->driver && hid->driver->suspend) {
+			status = hid->driver->suspend(hid, 0);
+			if (status < 0)
+				return status;
+		}
 		spin_lock_irq(&usbhid->lock);
 		set_bit(HID_REPORTED_IDLE, &usbhid->iofl);
 		spin_unlock_irq(&usbhid->lock);
@@ -1352,6 +1362,11 @@ static int hid_resume(struct usb_interface *intf)
 		hid_io_error(hid);
 	usbhid_restart_queues(usbhid);
 
+	if (status >= 0 && hid->driver && hid->driver->resume) {
+		int ret = hid->driver->resume(hid);
+		if (ret < 0)
+			status = ret;
+	}
 	dev_dbg(&intf->dev, "resume status %d\n", status);
 	return 0;
 }
@@ -1360,9 +1375,16 @@ static int hid_reset_resume(struct usb_interface *intf)
 {
 	struct hid_device *hid = usb_get_intfdata(intf);
 	struct usbhid_device *usbhid = hid->driver_data;
+	int status;
 
 	clear_bit(HID_REPORTED_IDLE, &usbhid->iofl);
-	return hid_post_reset(intf);
+	status = hid_post_reset(intf);
+	if (status >= 0 && hid->driver && hid->driver->reset_resume) {
+		int ret = hid->driver->reset_resume(hid);
+		if (ret < 0)
+			status = ret;
+	}
+	return status;
 }
 
 #endif /* CONFIG_PM */
include/linux/hid.h +8 -0
index b1344ec..a2f3612 100644
@@ -589,6 +589,9 @@ struct hid_usage_id {
  * @report_fixup: called before report descriptor parsing (NULL means nop)
  * @input_mapping: invoked on input registering before mapping an usage
  * @input_mapped: invoked on input registering after mapping an usage
+ * @suspend: invoked on suspend (NULL means nop)
+ * @resume: invoked on resume if device was not reset (NULL means nop)
+ * @reset_resume: invoked on resume if device was reset (NULL means nop)
  *
  * raw_event and event should return 0 on no action performed, 1 when no
  * further processing should be done and negative on error
@@ -629,6 +632,11 @@ struct hid_driver {
 	int (*input_mapped)(struct hid_device *hdev,
 			struct hid_input *hidinput, struct hid_field *field,
 			struct hid_usage *usage, unsigned long **bit, int *max);
+#ifdef CONFIG_PM
+	int (*suspend)(struct hid_device *hdev, int auto_suspend);
+	int (*resume)(struct hid_device *hdev);
+	int (*reset_resume)(struct hid_device *hdev);
+#endif
 /* private: */
 	struct device_driver driver;
 };
Signature · 6 lines
1.6.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#24 lore raw

Re: [PATCH v6 7/8, needs improvement] hid: add suspend/resume hooks for hid drivers

Am Sonntag, 11. April 2010 13:02:26 schrieb Bruno Prémont:

Quoted 3 lines

Where do I find the bluetooth HID bits? I've been searching through kernel sources (under drivers/) but did not find bluetooth code trying to register a HID device...

net/bluetooth/hidp/core.c

Quoted 3 lines

Below an updated patch which also calls the hook for auto-suspend case. The patch compiles but I've not runtime-tested it yet (especially for the auto-suspend part, as I'm not sure what should trigger it).

Looks basically good.

Quoted 3 lines

As far as I understand the code, in auto-suspend case if the driver sends commands to the device it will have to call usbhid_wait_io(). Please correct me if I'm wrong!

No, only if it wants to know that the command has finished. hid_submit_out() will queue IO in the autosuspended case and schedule a resumption.

include/linux/hid.h struct hid_driver { · line 636

Quoted 6 lines
include/linux/hid.h +2 -0
@@ -629,6 +632,11 @@ struct hid_driver {
        int (*input_mapped)(struct hid_device *hdev,
                        struct hid_input *hidinput, struct hid_field *field,
                        struct hid_usage *usage, unsigned long **bit, int *max);
+#ifdef CONFIG_PM
+       int (*suspend)(struct hid_device *hdev, int auto_suspend);

It would be better to pass the full message.

Regards
Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#25 lore raw

Re: [PATCH v6 7/8, needs improvement] hid: add suspend/resume hooks for hid drivers

In reply to Bruno Prémont
Quoted 7 lines · Bruno Prémont
Quoted 3 lines

We should also consider putting the hook calls into bluetooth implementation as well (though there is currently no driver using it, but I don't know, maybe Wacom could benefit from it as well).

Where do I find the bluetooth HID bits? I've been searching through kernel sources (under drivers/) but did not find bluetooth code trying to register a HID device...

They are in net/bluetooth/hidp. Not really obvious, I know, but Marcel wanted it this way.

Quoted 3 lines

As far as I understand the code, in auto-suspend case if the driver sends commands to the device it will have to call usbhid_wait_io(). Please correct me if I'm wrong!

It's not needed. There is a queuing mechanism in place on 'resumption_waker' workqueue.

Signature · 6 lines
Jiri Kosina
SUSE Labs, Novell Inc.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author maintainer
#26 lore raw

Re: [PATCH v6 7/8, needs improvement] hid: add suspend/resume hooks for hid drivers

Quoted 6 lines · On Sun, 11 April 2010 Jiri Kosina <[email protected]> wrote:
Quoted 3 lines

As far as I understand the code, in auto-suspend case if the driver sends commands to the device it will have to call usbhid_wait_io(). Please correct me if I'm wrong!

It's not needed. There is a queuing mechanism in place on 'resumption_waker' workqueue.

So the driver is not allowed to ask the device to do something at auto-suspend time (as that would abort the auto-suspension).

Am I right?

Thanks,
Bruno

#27 lore raw

Re: [PATCH v6 7/8, needs improvement] hid: add suspend/resume hooks for hid drivers

Am Sonntag, 11. April 2010 20:40:02 schrieb Bruno Prémont:

Quoted 10 lines · On Sun, 11 April 2010 Jiri Kosina <[email protected]> wrote:
Quoted 6 lines
Quoted 3 lines

As far as I understand the code, in auto-suspend case if the driver sends commands to the device it will have to call usbhid_wait_io(). Please correct me if I'm wrong!

It's not needed. There is a queuing mechanism in place on 'resumption_waker' workqueue.

So the driver is not allowed to ask the device to do something at auto-suspend time (as that would abort the auto-suspension).

From within suspend()?

Generally if the driver wants to talk to a device that's a good reason to wake up a device.

Regards
Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#28 lore raw

Re: [PATCH v6 7/8, needs improvement] hid: add suspend/resume hooks for hid drivers

In reply to Bruno Prémont
Quoted 9 lines · Bruno Prémont
Quoted 6 lines
Quoted 3 lines

As far as I understand the code, in auto-suspend case if the driver sends commands to the device it will have to call usbhid_wait_io(). Please correct me if I'm wrong!

It's not needed. There is a queuing mechanism in place on 'resumption_waker' workqueue.

So the driver is not allowed to ask the device to do something at auto-suspend time (as that would abort the auto-suspension).

What do you mean by "is not allowed" exactly?

Yes, it will wake the device up from auto-suspension. However, that's usually what you want to happen, is there is anything you need to dispatch to the device, isn't it?

What exactly is the situation you are trying to handle?

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.
author maintainer
#29 lore raw

Re: [PATCH v6 7/8, needs improvement] hid: add suspend/resume hooks for hid drivers

Quoted 9 lines · On Mon, 12 April 2010 Jiri Kosina <[email protected]> wrote:
Quoted 7 lines · Bruno Prémont
Quoted 6 lines
Quoted 3 lines

As far as I understand the code, in auto-suspend case if the driver sends commands to the device it will have to call usbhid_wait_io(). Please correct me if I'm wrong!

It's not needed. There is a queuing mechanism in place on 'resumption_waker' workqueue.

Quoted 8 lines
Quoted 2 lines

So the driver is not allowed to ask the device to do something at auto-suspend time (as that would abort the auto-suspension).

What do you mean by "is not allowed" exactly?

Yes, it will wake the device up from auto-suspension. However, that's usually what you want to happen, is there is anything you need to dispatch to the device, isn't it?

I thought of a report to send to device to ask the device to disable some power using feature (e.g. turning off or dimming LEDs)

Quoted 1 line

What exactly is the situation you are trying to handle?

That's rather a generic question, not related to any implementation.

Maybe I'm mixing suspend and USB-autosuspend too much?

Thanks,
Bruno
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#30 lore raw

Re: [PATCH v6 7/8, needs improvement] hid: add suspend/resume hooks for hid drivers

Am Montag, 12. April 2010 18:56:07 schrieb Bruno Prémont:

Quoted 6 lines
Quoted 3 lines

Yes, it will wake the device up from auto-suspension. However, that's usually what you want to happen, is there is anything you need to dispatch to the device, isn't it?

I thought of a report to send to device to ask the device to disable some power using feature (e.g. turning off or dimming LEDs)

The device should do this on its own. If it is really necessary you can do this in suspend()

Regards
Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#31 lore raw

PATCH v6 8/8 hid: add PM support to PicoLCD device

In reply to Bruno Prémont

Add PM support in order to turn off backlight on suspend, restore it on resume and especially restore complete state on reset-resume.

---
 drivers/hid/hid-picolcd.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)
drivers/hid/hid-picolcd.c +42 -0
index fe1f772..daa7c5d 100644
@@ -2255,6 +2255,43 @@ static int picolcd_raw_event(struct hid_device *hdev,
 	return 1;
 }
 
+#ifdef CONFIG_PM
+static int picolcd_suspend(struct hid_device *hdev)
+{
+	picolcd_suspend_backlight(hid_get_drvdata(hdev));
+	dbg_hid(PICOLCD_NAME " device ready for suspend\n");
+	return 0;
+}
+
+static int picolcd_resume(struct hid_device *hdev)
+{
+	int ret;
+	ret = picolcd_resume_backlight(hid_get_drvdata(hdev));
+	if (ret)
+		dbg_hid(PICOLCD_NAME " restoring backlight failed: %d\n", ret);
+	return 0;
+}
+
+static int picolcd_reset_resume(struct hid_device *hdev)
+{
+	int ret;
+	ret = picolcd_reset(hdev);
+	if (ret)
+		dbg_hid(PICOLCD_NAME " resetting our device failed: %d\n", ret);
+	ret = picolcd_fb_reset(hid_get_drvdata(hdev), 0);
+	if (ret)
+		dbg_hid(PICOLCD_NAME " restoring framebuffer content failed: %d\n", ret);
+	ret = picolcd_resume_lcd(hid_get_drvdata(hdev));
+	if (ret)
+		dbg_hid(PICOLCD_NAME " restoring lcd failed: %d\n", ret);
+	ret = picolcd_resume_backlight(hid_get_drvdata(hdev));
+	if (ret)
+		dbg_hid(PICOLCD_NAME " restoring backlight failed: %d\n", ret);
+	picolcd_leds_set(hid_get_drvdata(hdev));
+	return 0;
+}
+#endif
+
 /* initialize keypad input device */
 static int picolcd_init_keys(struct picolcd_data *data,
 		struct hid_report *report)
@@ -2530,6 +2567,11 @@ static struct hid_driver picolcd_driver = {
 	.probe =         picolcd_probe,
 	.remove =        picolcd_remove,
 	.raw_event =     picolcd_raw_event,
+#ifdef CONFIG_PM
+	.suspend =       picolcd_suspend,
+	.resume =        picolcd_resume,
+	.reset_resume =  picolcd_reset_resume,
+#endif
 };
 
 static int __init picolcd_init(void)
Signature · 1 line
1.6.4.4
#32 lore raw
In reply to Bruno Prémont
Quoted 5 lines · Bruno Prémont
Quoted 2 lines

so please either remove the parts that depend on power management for now, or I'll wait on your respin of the generic HID-PM patch.

Here I respin the whole series, with PM moved to patch n°8 and patch n°7 being my original generic HID-PM.

Thanks!

Quoted 4 lines

Without the PM part there is one compiler warning about defined but unused function (picolcd_resume_backlight), I hope this is not an issue. If it is that function can move over to the PM patch (with it's stub for !CONFIG_BACKLIGHT_CLASS_DEVICE case)

It's actually picolcd_suspend_backlight(), the resume function is called from debugfs-triggered reset write.

I have removed it from the patch for now, it should better be added when being used (i.e. when the proper PM support goes in as well).

Quoted 1 line

So for now you can skip the last two patches during merge.

I have applied patches 1-6 to my tree. So please base any further additions to the driver on the version that's in my tree now (picolcd and for-next branches).

Quoted 2 lines

Do you have any suggestions regarding generic HID-PM as to how much and how it should be visible to the HID driver?

I will look into the patch you have sent and comment on that shortly separately.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.
author maintainer
#33 lore raw

PATCH v3 2/6 hid: add framebuffer support to PicoLCD device

In reply to Bruno Prémont

Add framebuffer support to PicoLCD device with use of deferred-io.

Only changed areas of framebuffer get sent to device in order to save USB bandwidth and especially resources on PicoLCD device or allow higher refresh rate for a small area. Changed tiles are determined while updating shadow framebuffer.

Changes since v2:
- add 8bit grayscale depth as near to no userspace app handles 1bit
- properly send whole framebuffer on reset/init
- drop inline keywords from non-stub functions
- use device_{create,remove}_file instead of sysfs_{create,remove}_file

---

Jaya, is my choice of FB_VISUAL_TRUECOLOR correct for grayscale 8bpp mode?

Userspace applications I tested with:
- links
Tested the 8bpp mode, works fine.
- fdbsee
Fails with a message mentioning font creation, so I assume it's unrelated to my implementation.
- fbv
Fails and complains about missing color map.
That one should not be needed for grayscale unless I'm missing something (documentation is rather poor)

I've not tested with Xorg as there is none installed on the test system.

 drivers/hid/Kconfig       |    7 +-
 drivers/hid/hid-picolcd.c |  544 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 549 insertions(+), 2 deletions(-)
drivers/hid/Kconfig +6 -1
index 138ba6a..a813ea9 100644
@@ -265,6 +265,11 @@ config HID_PETALYNX
 config HID_PICOLCD
 	tristate "PicoLCD (graphic version)"
 	depends on USB_HID
+	select FB_DEFERRED_IO if FB
+	select FB_SYS_FILLRECT if FB
+	select FB_SYS_COPYAREA if FB
+	select FB_SYS_IMAGEBLIT if FB
+	select FB_SYS_FOPS if FB
 	---help---
 	  This provides support for Minibox PicoLCD devices, currently
 	  only the graphical ones are supported.
@@ -272,8 +277,8 @@ config HID_PICOLCD
 	  This includes support for the following device features:
 	  - Keypad
 	  - Switching between Firmware and Flash mode
-	  Features that are not (yet) supported:
 	  - Framebuffer for monochrome 256x64 display
+	  Features that are not (yet) supported:
 	  - Backlight control
 	  - Contrast control
 	  - IR
drivers/hid/hid-picolcd.c +543 -1

610 lines not on this page · raw message

Signature · 1 line
1.6.4.4
author maintainer
#34 lore raw

PATCH v4 2/6 hid: add framebuffer support to PicoLCD device

Add framebuffer support to PicoLCD device with use of deferred-io.

Only changed areas of framebuffer get sent to device in order to save USB bandwidth and especially resources on PicoLCD device or allow higher refresh rate for a small area. Changed tiles are determined while updating shadow framebuffer.

Changes since v3:
- document fb_update_rate sysfs attribute
- change fb_update_rate read behavior to match enum with selected in brackets presentation
Changes since v2:
- add 8bit grayscale depth as near to no userspace app handles 1bit
- properly send whole framebuffer on reset/init
- drop inline keywords from non-stub functions
- use device_{create,remove}_file instead of sysfs_{create,remove}_file

---
 Documentation/ABI/testing/sysfs-driver-hid-picolcd |   17 +
 drivers/hid/Kconfig                                |    7 +-
 drivers/hid/hid-picolcd.c                          |  553 +++++++++++++++++++-
 3 files changed, 575 insertions(+), 2 deletions(-)
Documentation/ABI/testing/sysfs-driver-hid-picolcd +17 -0
index 6fb4f21..14f52d7 100644
@@ -15,3 +15,20 @@ Description:	Make it possible to switch the PicoLCD device between LCD
 		disconnected and reconnects after above delay (default value
 		is 5 seconds though this default should not be relied on).
 
+
+What:		/sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/fb_update_rate
+Date:		March 2010
+Contact:	Bruno Prémont <[email protected]>
+Description:	Make it possible to adjust defio refresh rate.
+
+		Reading: returns list of available refresh rates (expressed in Hz),
+		the active refresh rate being enclosed in brackets ('[' and ']')
+
+		Writing: accepts new refresh rate expressed in integer Hz
+		within permitted rates.
+
+		Note: As device can barely do 2 complete refreshes a second
+		it only makes sense to adjust this value if only one or two
+		tiles get changed and it's not appropriate to expect the application
+		to flush it's tiny changes explicitely at higher than default rate.
+
drivers/hid/Kconfig +6 -1
index 138ba6a..a813ea9 100644
@@ -265,6 +265,11 @@ config HID_PETALYNX
 config HID_PICOLCD
 	tristate "PicoLCD (graphic version)"
 	depends on USB_HID
+	select FB_DEFERRED_IO if FB
+	select FB_SYS_FILLRECT if FB
+	select FB_SYS_COPYAREA if FB
+	select FB_SYS_IMAGEBLIT if FB
+	select FB_SYS_FOPS if FB
 	---help---
 	  This provides support for Minibox PicoLCD devices, currently
 	  only the graphical ones are supported.
@@ -272,8 +277,8 @@ config HID_PICOLCD
 	  This includes support for the following device features:
 	  - Keypad
 	  - Switching between Firmware and Flash mode
-	  Features that are not (yet) supported:
 	  - Framebuffer for monochrome 256x64 display
+	  Features that are not (yet) supported:
 	  - Backlight control
 	  - Contrast control
 	  - IR
drivers/hid/hid-picolcd.c +552 -1

619 lines not on this page · raw message

Signature · 1 line
1.6.4.4
author maintainer
#35 lore raw

PATCH v5 2/6 hid: add framebuffer support to PicoLCD device

Add framebuffer support to PicoLCD device with use of deferred-io.

Only changed areas of framebuffer get sent to device in order to save USB bandwidth and especially resources on PicoLCD device or allow higher refresh rate for a small area. Changed tiles are determined while updating shadow framebuffer.

Changes since v4:
- make backbuffer inconsistent with framebuffer to force refresh in picolcd_fb_reset (e.g. for reset_resume)
- force picolcd_fb_update() to wait for urbs to get out of the queue when it sends more than 1/2 queue worth as a full display refresh fills the whole queue eventually causing queue overrun (and lost report) on a quick system
Changes since v3:
- document fb_update_rate sysfs attribute
- change fb_update_rate read behavior to match enum with selected in brackets presentation
Changes since v2:
- add 8bit grayscale depth as near to no userspace app handles 1bit
- properly send whole framebuffer on reset/init
- drop inline keywords from non-stub functions
- use device_{create,remove}_file instead of sysfs_{create,remove}_file

---

Because on a quick system I get "output queue full" messages (and incomplete update of device's display) when a full framebuffer has to be transmitted back to PicoLCD device I have to wait on the queue to get a few reports out.
Instead of duplicating "usbhid_wait_io()" I marked it with EXPORT_SYMBOL_GPL so I can still build hid-picolcd as a module.

 Documentation/ABI/testing/sysfs-driver-hid-picolcd |   17 +
 drivers/hid/Kconfig                                |    7 +-
 drivers/hid/hid-picolcd.c                          |  570 +++++++++++++++++++-
 drivers/hid/usbhid/hid-core.c                      |    1 +
 4 files changed, 593 insertions(+), 2 deletions(-)
Documentation/ABI/testing/sysfs-driver-hid-picolcd +17 -0
index 6fb4f21..14f52d7 100644
@@ -15,3 +15,20 @@ Description:	Make it possible to switch the PicoLCD device between LCD
 		disconnected and reconnects after above delay (default value
 		is 5 seconds though this default should not be relied on).
 
+
+What:		/sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/fb_update_rate
+Date:		March 2010
+Contact:	Bruno Prémont <[email protected]>
+Description:	Make it possible to adjust defio refresh rate.
+
+		Reading: returns list of available refresh rates (expressed in Hz),
+		the active refresh rate being enclosed in brackets ('[' and ']')
+
+		Writing: accepts new refresh rate expressed in integer Hz
+		within permitted rates.
+
+		Note: As device can barely do 2 complete refreshes a second
+		it only makes sense to adjust this value if only one or two
+		tiles get changed and it's not appropriate to expect the application
+		to flush it's tiny changes explicitely at higher than default rate.
+
drivers/hid/Kconfig +6 -1
index 138ba6a..a813ea9 100644
@@ -265,6 +265,11 @@ config HID_PETALYNX
 config HID_PICOLCD
 	tristate "PicoLCD (graphic version)"
 	depends on USB_HID
+	select FB_DEFERRED_IO if FB
+	select FB_SYS_FILLRECT if FB
+	select FB_SYS_COPYAREA if FB
+	select FB_SYS_IMAGEBLIT if FB
+	select FB_SYS_FOPS if FB
 	---help---
 	  This provides support for Minibox PicoLCD devices, currently
 	  only the graphical ones are supported.
@@ -272,8 +277,8 @@ config HID_PICOLCD
 	  This includes support for the following device features:
 	  - Keypad
 	  - Switching between Firmware and Flash mode
-	  Features that are not (yet) supported:
 	  - Framebuffer for monochrome 256x64 display
+	  Features that are not (yet) supported:
 	  - Backlight control
 	  - Contrast control
 	  - IR
drivers/hid/hid-picolcd.c +569 -1

636 lines not on this page · raw message

drivers/hid/usbhid/hid-core.c +1 -0
index 39fe2e8..9acf573 100644
@@ -623,6 +623,7 @@ int usbhid_wait_io(struct hid_device *hid)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(usbhid_wait_io);
 
 static int hid_set_idle(struct usb_device *dev, int ifnum, int report, int idle)
 {
Signature · 1 line
1.6.4.4
author maintainer
#36 lore raw

PATCH v3 3/6 hid: add backlight support to PicoLCD device

In reply to Bruno Prémont

Add backlight support to PicoLCD device.

Backlight support depends on backlight class and is only being compiled if backlight class has been selected.

Changes since v2:
- Drop inline keyword on non-stub functions

---
 drivers/hid/Kconfig       |    2 +-
 drivers/hid/hid-picolcd.c |  136 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 136 insertions(+), 2 deletions(-)
drivers/hid/Kconfig +1 -1
index a813ea9..588b9ac 100644
@@ -278,8 +278,8 @@ config HID_PICOLCD
 	  - Keypad
 	  - Switching between Firmware and Flash mode
 	  - Framebuffer for monochrome 256x64 display
+	  - Backlight control    (needs CONFIG_BACKLIGHT_CLASS_DEVICE)
 	  Features that are not (yet) supported:
-	  - Backlight control
 	  - Contrast control
 	  - IR
 	  - General purpose outputs
drivers/hid/hid-picolcd.c +135 -1

204 lines not on this page · raw message

Signature · 1 line
1.6.4.4
author maintainer
#37 lore raw

PATCH v3 4/6 hid: add lcd support to PicoLCD device

In reply to Bruno Prémont

Add lcd support to PicoLCD device.

LCD support depends on lcd class and is only being compiled if lcd class has been selected.

Changes since v2:
- Drop inline keyword on non-stub functions

---
 drivers/hid/Kconfig       |    2 +-
 drivers/hid/hid-picolcd.c |  109 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 110 insertions(+), 1 deletions(-)
drivers/hid/Kconfig +1 -1
index 588b9ac..399edc5 100644
@@ -279,8 +279,8 @@ config HID_PICOLCD
 	  - Switching between Firmware and Flash mode
 	  - Framebuffer for monochrome 256x64 display
 	  - Backlight control    (needs CONFIG_BACKLIGHT_CLASS_DEVICE)
+	  - Contrast control     (needs CONFIG_LCD_CLASS_DEVICE)
 	  Features that are not (yet) supported:
-	  - Contrast control
 	  - IR
 	  - General purpose outputs
 	  - EEProm / Flash access
drivers/hid/hid-picolcd.c +109 -0

157 lines not on this page · raw message

Signature · 1 line
1.6.4.4
author maintainer
#38 lore raw

PATCH v3 5/6 hid: add GPO (leds) support to PicoLCD device

In reply to Bruno Prémont

Add leds support to PicoLCD device to drive the GPO pins.

GPO support depends on leds class and is only being compiled if leds class has been selected.

Changes since v2:
- Drop inline keyword on non-stub functions

---
 drivers/hid/Kconfig       |    6 +-
 drivers/hid/hid-picolcd.c |  164 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 167 insertions(+), 3 deletions(-)
drivers/hid/Kconfig +3 -3
index 399edc5..34f6593 100644
@@ -278,11 +278,11 @@ config HID_PICOLCD
 	  - Keypad
 	  - Switching between Firmware and Flash mode
 	  - Framebuffer for monochrome 256x64 display
-	  - Backlight control    (needs CONFIG_BACKLIGHT_CLASS_DEVICE)
-	  - Contrast control     (needs CONFIG_LCD_CLASS_DEVICE)
+	  - Backlight control         (needs CONFIG_BACKLIGHT_CLASS_DEVICE)
+	  - Contrast control          (needs CONFIG_LCD_CLASS_DEVICE)
+	  - General purpose outputs   (needs CONFIG_LEDS_CLASS)
 	  Features that are not (yet) supported:
 	  - IR
-	  - General purpose outputs
 	  - EEProm / Flash access
 
 config HID_QUANTA
drivers/hid/hid-picolcd.c +164 -0

212 lines not on this page · raw message

Signature · 1 line
1.6.4.4
author maintainer
#39 lore raw

PATCH v3 6/6 hid: add experimental access to PicoLCD device's EEPROM and FLASH

In reply to Bruno Prémont

The PicoLCD device has a small amount of EEPROM and also provides access to its FLASH where firmware and splash image are saved.
In flasher mode FLASH access is the only active feature.

Give read/write access to both via debugfs files.

NOTE: EEPROM and FLASH access should be switched to better suited API,
until then they will reside in debugfs

Changes since v2:
- Drop inline keyword on non-stub functions
- Prevent interleaved flash writes via mutex
- Add description of flash/eeprom access schematics

---
 drivers/hid/Kconfig       |    2 +-
 drivers/hid/hid-picolcd.c |  439 +++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 423 insertions(+), 18 deletions(-)
drivers/hid/Kconfig +1 -1
index 34f6593..a2ecd83 100644
@@ -281,9 +281,9 @@ config HID_PICOLCD
 	  - Backlight control         (needs CONFIG_BACKLIGHT_CLASS_DEVICE)
 	  - Contrast control          (needs CONFIG_LCD_CLASS_DEVICE)
 	  - General purpose outputs   (needs CONFIG_LEDS_CLASS)
+	  - EEProm / Flash access     (via debugfs)
 	  Features that are not (yet) supported:
 	  - IR
-	  - EEProm / Flash access
 
 config HID_QUANTA
 	tristate "Quanta Optical Touch"
drivers/hid/hid-picolcd.c +422 -17

489 lines not on this page · raw message

Signature · 1 line
1.6.4.4
#40 lore raw

Re: [PATCH v3 6/6] hid: add experimental access to PicoLCD device's EEPROM and FLASH

drivers/hid/hid-picolcd.c static DEVICE_ATTR(operation_mode, 0644, picolcd_operation_mode_show, · line 1323

Quoted 5 lines · Bruno Prémont
drivers/hid/hid-picolcd.c +5 -0
+static ssize_t picolcd_debug_reset_open(struct inode *inode, struct file *f)
+{
+	return single_open(f, picolcd_debug_reset_show, inode->i_private);
+}
+

struct file_operations->open is supposed to return int (filedescriptor), not ssize_t.

Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.
author maintainer
#41 lore raw

PATCH v4 6/6 hid: add experimental access to PicoLCD device's EEPROM and FLASH

The PicoLCD device has a small amount of EEPROM and also provides access to its FLASH where firmware and splash image are saved.
In flasher mode FLASH access is the only active feature.

Give read/write access to both via debugfs files.

NOTE: EEPROM and FLASH access should be switched to better suited API,
until then the will reside in debugfs

Changes since v3:
- Fix return value of picolcd_debug_reset_open
Changes since v2:
- Drop inline keyword on non-stub functions
- Prevent interleaved flash writes via mutex
- Add description of flash/eeprom access schematincs

---

Quoted 10 lines · On Mon, 29 March 2010 Jiri Kosina <[email protected]> wrote:

Review

Quoted 5 lines · Bruno Prémont
(quoted diff) +5 -0
+static ssize_t picolcd_debug_reset_open(struct inode *inode, struct file *f)
+{
+	return single_open(f, picolcd_debug_reset_show, inode->i_private);
+}
+

struct file_operations->open is supposed to return int (filedescriptor), not ssize_t.

Fixed with this updated patch, thanks for noticing.
(today I compiled on both x86 32bit and 64bit without compiler warnings,
so hopefully no remaining type mixes of that kind)

 drivers/hid/Kconfig       |    2 +-
 drivers/hid/hid-picolcd.c |  439 +++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 423 insertions(+), 18 deletions(-)
drivers/hid/Kconfig +1 -1
index 34f6593..a2ecd83 100644
@@ -281,9 +281,9 @@ config HID_PICOLCD
 	  - Backlight control         (needs CONFIG_BACKLIGHT_CLASS_DEVICE)
 	  - Contrast control          (needs CONFIG_LCD_CLASS_DEVICE)
 	  - General purpose outputs   (needs CONFIG_LEDS_CLASS)
+	  - EEProm / Flash access     (via debugfs)
 	  Features that are not (yet) supported:
 	  - IR
-	  - EEProm / Flash access
 
 config HID_QUANTA
 	tristate "Quanta Optical Touch"
drivers/hid/hid-picolcd.c +422 -17

489 lines not on this page · raw message

Signature · 1 line
1.6.4.4