Qt 5.4 Linux Touchscreen Input with Tslib on Raspberry Pi failing with LinuxFB QPA Platform Plugin - linux

I bought a Tontec 2.4 Inch Touchscreen ( http://elinux.org/MZTX-PI-EXT ) for my Raspberry Pi. The touchscreen controller requires the "tsc2007.ko" and "tsp_raspi.ko" kernel modules as described in the elinux post. The tsc2007.ko module is in the Raspbian Kernel tree but the tsp_raspi.ko can be found here: https://github.com/osandov/raspi/tree/master/tsc2007.
I've cross compiled a new Kernel for the Pi with those modules and they load fine and create a /dev/input/event0 device in Raspbian. If I 'evtest' that device and touch the screen, I get output so I know the events are being delivered in Linux:
pi#raspberry /dev/input $ evtest
Available devices:
/dev/input/event0: TSC2007 Touchscreen
Select the device event number [0-0]: 0
Input driver version is 1.0.1
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "TSC2007 Touchscreen"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 330 (BTN_TOUCH)
Event type 3 (EV_ABS)
Event code 0 (ABS_X)
Value 1922
Min 0
Max 4095
Fuzz 64
Event code 1 (ABS_Y)
Value 2221
Min 0
Max 4095
Fuzz 64
Event code 24 (ABS_PRESSURE)
Value 0
Min 0
Max 4095
Fuzz 64
Properties:
Testing ... (interrupt to exit)
Event: time 1425521704.199489, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
Event: time 1425521704.199489, type 3 (EV_ABS), code 1 (ABS_Y), value 2085
Event: time 1425521704.199489, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 538
Event: time 1425521704.199489, -------------- SYN_REPORT ------------
Event: time 1425521704.209174, type 3 (EV_ABS), code 0 (ABS_X), value 1455
...
I installed tslib and ran a quick ts_calibrate. I also made sure that ts_test spit out data when I touched the screen.
I added the following environment variables to /etc/profile for tslib support in Qt5:
## For Qt5 Touchscreen Support
export QT_DEBUG_PLUGINS=1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/arm-linux-gnueabihf/
export QT_PLUGIN_PATH=/usr/lib/plugins
export QT_QPA_FONTDIR=/usr/lib/fonts
export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/plugins/platforms
export QT_QPA_PLATFORM=linuxfb
export QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event0
export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event0
export TSLIB_TSEVENTTYPE='INPUT'
export TSLIB_CALIBFILE='/etc/pointercal'
export TSLIB_CONFFILE='/etc/ts.conf'
export TSLIB_CONSOLEDEVICE='none'
export TSLIB_FBDEVICE='/dev/fb0'
export TSLIB_PLUGINDIR='/usr/lib/ts'
export TSLIB_TSDEVICE='/dev/input/event0'
I read up on the Qt5 docs and how to get touch events in my app. I have a main Widget and set the appropriate flags in the constructor:
MainWidget::MainWidget(QLabel *parent)
: QLabel(parent)
{
qDebug() << "Setting WA_AcceptTouchEvents on MainWidget...";
// Accept touch events
setAttribute(Qt::WA_AcceptTouchEvents);
setAttribute(Qt::WA_StaticContents);
}
I setup an event filter to try to catch the touch events:
bool MainWidget::eventFilter( QObject* target, QEvent* e )
{
qDebug() << "Event Type: " << e->type();
return false;
return QLabel::eventFilter(target, e);
}
I launch my app like this:
myapp -platform linuxfb:fb=/dev/fb0 -plugin tslib:/dev/input/event0
I also uncommented a single printf in Qt's source code for the qtslib.cpp:
void QTsLibMouseHandler::readMouseData()
{
ts_sample sample;
while (get_sample(m_dev, &sample, m_rawMode)) {
bool pressed = sample.pressure;
int x = sample.x;
int y = sample.y;
// work around missing coordinates on mouse release
if (sample.pressure == 0 && sample.x == 0 && sample.y == 0) {
x = m_x;
y = m_y;
}
if (!m_rawMode) {
//filtering: ignore movements of 2 pixels or less
int dx = x - m_x;
int dy = y - m_y;
if (dx*dx <= 4 && dy*dy <= 4 && pressed == m_pressed)
continue;
}
QPoint pos(x, y);
//printf("handleMouseEvent %d %d %d %ld\n", m_x, m_y, pressed, sample.tv.tv_usec);
QWindowSystemInterface::handleMouseEvent(0, pos, pos, pressed ? Qt::LeftButton : Qt::NoButton);
m_x = x;
m_y = y;
m_pressed = pressed;
}
}
When I launch my Qt app I see the plugins are loading OK ( even shows the correct event0 file ). I also see that the qt tslib plugin is receiving touch events when I touch the screen. The problem is that the event filter is NEVER called!
Here is the app being launched:
Got keys from plugin meta data ("tslib", "tslibraw")
QFactoryLoader::QFactoryLoader() checking directory path "/home/pi/generic" ...
loaded library "/usr/lib/qt/plugins/generic/libqtslibplugin.so"
QTsLibMouseHandler "tslib" ""
QTsLibMouseHandler "tslib" "/dev/input/event0"
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/qt/plugins/styles" ...
QFactoryLoader::QFactoryLoader() checking directory path "/home/pi/styles" ...
Setting WA_AcceptTouchEvents on MainWidget...
-----------------------------------------
Waiting for data now...
-----------------------------------------
handleMouseEvent 0 0 1 751196
handleMouseEvent 0 0 1 751196
handleMouseEvent 1696 1615 1 771075
handleMouseEvent 1696 1615 1 771075
handleMouseEvent 1679 1622 1 781368
handleMouseEvent 1671 1638 1 781368
handleMouseEvent 1679 1622 1 781368
handleMouseEvent 1671 1638 1 781368
...
I found a few forum posts where people are having problems with touch input with the linuxfb platform plugin:
http://comments.gmane.org/gmane.comp.lib.qt.user/5686
http://qt-project.org/forums/viewthread/35757
http://qt-project.org/forums/viewthread/36120/
I've tried all their suggestions and still have the problem - no touch events are received by my app even though the Qt tslib plugin says it is receiving them.
It seems that the tslib plugin is having problems injecting the event it receives into my app's event loop with this:
QWindowSystemInterface::handleMouseEvent(0, pos, pos, pressed ? Qt::LeftButton : Qt::NoButton);
I also tried the Qt5.4 touch fingerpaint example and see the same behavior - no touch events are received.
I'm not sure where to go from here. I would greatly appreciate any help solving this issue. Thanks!
UPDATE:
I changed my event filter so it looks like this:
bool MainWidget::eventFilter(QObject *obj, QEvent *event)
{
qDebug() << "Event received" << obj->metaObject()->className() << event->type();
switch (event->type()) {
case QEvent::TouchBegin:
qDebug() << "TouchBegin";
case QEvent::TouchUpdate:
qDebug() << "TouchUpdate";
case QEvent::TouchEnd:
qDebug() << "TouchEnd";
{
// QTouchEvent *touch = static_cast<QTouchEvent *>(event);
// QList<QTouchEvent::TouchPoint> touchPoints = static_cast<QTouchEvent *>(event)->touchPoints();
// foreach (const QTouchEvent::TouchPoint &touchPoint, touchPoints) {
// switch (touchPoint.state()) {
// case Qt::TouchPointStationary:
// // don't do anything if this touch point hasn't moved
// continue;
// default:
// {
// }
// break;
// }
// }
// break;
}
//default:
//return QLabel::event(event);
}
//return true;
}
Now I can see 'socket notifier' events intermingled with Qt Tslib Plugin's prints whenever I touch the screen. Any ideas as to why Event Type 50 but no Touch Events?
Event received QSocketNotifier 50
handleMouseEvent 2702 2618 0 557715
Event received QSocketNotifier 50
handleMouseEvent 2698 2612 1 547758
Event received QSocketNotifier 50
handleMouseEvent 2706 2802 1 759928
Event received QSocketNotifier 50
Event received QSocketNotifier 50
UPDATE #2:
I installed the event filter only to try to catch any events. I'm not sure in Qt5 what translates an event type 50 ( QSocketNotifier ) to a QTouch* or QMouse* event.
Here is some more information:
When I run evtest, I see that the screen resolution is huge ( ~2500 x
~2500 ) and the actual screen is 320x240. I tried changed the
/dev/fb0 framebuffer size in /boot/config.txt to 320x240 and
rebooted. But the evtest and ts_calibrate steps still show the huge
resolution.
Because of the large resolution, I tried making my main widget
10000x10000 to see if I would get a touch or mouse event - but I
still only get the QSocketNotifier
I then tried to force the tslib plugin to always inject events at
screen position X=50 Y=50, but I still only get the event type 50
QSocketNotifier.

The problem was solved by making sure the tslib plugins were installed on the RasbperryPi.
TSLIB_PLUGINDIR=/usr/lib/ts
The directory /usr/lib/ts was not present on the Pi.

Related

The device tree header verification error was encountered during uboot startup

I have a problem when using orangepi3.
I have an image that can be used under normal circumstances,
but the following problem occasionally occurs.
Once this problem occurs, the image burned in this time can no longer be used, and only the burned image can be reproduced
The following errors are reported during uboot startup.
Hit any key to stop autoboot: 0
no mmc device at slot 0
mmc2(part 0) is current device
2512 bytes read in 5 ms (490.2 KiB/s)
## Executing script at 43100000
U-boot loaded from SD
Boot script loaded from mmc
** Bad device mmc 0 **
** File not found /boot/dtb/sunxi/sun50i-h6-orangepi3.dtb **
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
8247895 bytes read in 404 ms (19.5 MiB/s)
19425352 bytes read in 945 ms (19.6 MiB/s)
but i am sure this file is exists;
Because when this error exists, I enter uboot and print the device tree. It can print correctly, but executing the command boot will still report this error.
And I checked the file system afterwards and found that the file exists in the path
.
I checked the uboot source code and found this error in the function fdt_check_header
int fdt_check_header(const void *fdt)
{
if (fdt_magic(fdt) == FDT_MAGIC) {
/* Complete tree */
if (fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION)
return -FDT_ERR_BADVERSION;
if (fdt_last_comp_version(fdt) > FDT_LAST_SUPPORTED_VERSION)
return -FDT_ERR_BADVERSION;
} else if (fdt_magic(fdt) == FDT_SW_MAGIC) {
/* Unfinished sequential-write blob */
if (fdt_size_dt_struct(fdt) == 0)
return -FDT_ERR_BADSTATE;
} else {
return -FDT_ERR_BADMAGIC;
}
return 0;
}
But in uboot init_sequence_f exe reserve_fdt also have the verification of the device tree header,and the verification has passed.
but in uboot autoboot_command run_command_list cmd_list an error occurred in the device tree header checked.resulting in failure to enter the kernel correctly.
Before entering FDT_ check_ I added a print function before the header function
Before entering the function fdt_check_header() I add a print like following in reserve_fdt()
static int reserve_fdt(void)
{
/*
* If the device tree is sitting immediate above our image then we
* must relocate it. If it is embedded in the data section, then it
* will be relocated with other data.
*/
if (gd->fdt_blob) {
pr_msg("reserve_fdt fdt_check_headeris %d\n",fdt_magic(gd->fdt_blob));
if(fdt_check_header(gd->fdt_blob) != 0)
{
pr_msg("fdt header check error\n");
return -1;
}
//reserve memory for expand dtb ,because cmd_fdt will update the base dtb
gd->fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob) + 0x1000, 32);
fdt_set_totalsize((void*)gd->fdt_blob,gd->fdt_size);
gd->start_addr_sp -= gd->fdt_size * 2;
gd->new_fdt = map_sysmem(gd->start_addr_sp, gd->fdt_size);
debug("Reserving %lu Bytes for FDT at: %08lx\n",
gd->fdt_size, gd->start_addr_sp);
}
return 0;
}
And in function fdt_valid() add too;
static int fdt_valid(struct fdt_header **blobp)
{
const void *blob = *blobp;
int err;
if (blob == NULL) {
printf ("The address of the fdt is invalid (NULL).\n");
return 0;
}
printf("fdt_valid fdt_check_header is %d\n",fdt_magic(blob));
err = fdt_check_header(blob);
if (err == 0)
return 1; /* valid */
if (err < 0) {
printf("libfdt fdt_check_header(): %s", fdt_strerror(err));
/*
* Be more informative on bad version.
*/
if (err == -FDT_ERR_BADVERSION) {
if (fdt_version(blob) <
FDT_FIRST_SUPPORTED_VERSION) {
printf (" - too old, fdt %d < %d",
fdt_version(blob),
FDT_FIRST_SUPPORTED_VERSION);
}
if (fdt_last_comp_version(blob) >
FDT_LAST_SUPPORTED_VERSION) {
printf (" - too new, fdt %d > %d",
fdt_version(blob),
FDT_LAST_SUPPORTED_VERSION);
}
}
printf("\n");
*blobp = NULL;
return 0;
}
return 1;
}
Then,when the error occurs,the log is as follows:
U-Boot 2014.07-orangepi (Oct 29 2021 - 09:07:58) Xunlong Software
[1.947]uboot commit : b65841975dcb31f64a2c69344f60db12b98791ae
[1.947]secure enable bit: 0
[1.947]normal mode: with secure monitor
I2C: ready
[1.949]pmbus: ready
[1.949][ARISC] :arisc initialize
[1.975][ARISC] :arisc para ok
[SCP] :sunxi-arisc driver begin startup 2
[SCP] :arisc version: []
[SCP] :sunxi-arisc driver v1.10 is starting
[1.987][ARISC] :sunxi-arisc driver startup succeeded
[1.989]PMU: AXP806
[1.989]PMU: AXP806 found
[1.989]bat_vol=0, ratio=0
[1.989]set pc_bias(1) bias:1800
[1.989]set pg_bias(5) bias:1800
[1.989]set power on vol to default
[1.989]dcdca_vol = 1000, onoff=1
[1.993]aldo2_vol = 3300, onoff=1
[1.998]bldo3_vol = 1800, onoff=1
[2.002]cldo2_vol = 3300, onoff=1
[2.006]cldo3_vol = 3300, onoff=1
[2.010]find power_sply to end
[2.010]cant find pll setting(1320M) from pll table,use default(408M)
[2.012]PMU: cpux 408 Mhz,AXI=204 Mhz
[2.013]PLL6=600 Mhz,AHB1=200 Mhz, APB1=100Mhz MBus=400Mhz
[2.017]DRAM: 1 GiB
[2.019]reserve_fdt fdt_check_headeris -804389139
[2.026]fdt addr: 0x79ccb0e0
[2.026]gd->fdt_size: 0x1a6c0
[2.030]Relocation Offset is: 34e03000
[2.095]gic: sec monitor mode
[2.095]line:180 func:check_ir_boot_recovery start
[2.095]ir boot recovery not used
[2.095][key recovery] no use
[2.096][box standby] read rtc = 0x0
[2.096][box standby] start_type = 0x1
[2.096][box standby] to kernel
[2.096]workmode = 0,storage type = 2
[2.098]MMC: 2
SUNXI SD/MMC: 2
[mmc]: [0-60|61]
[mmc]: [0-51|52]
[mmc]: [7-48|42]
[mmc]: [0-11|12] [26-29|4] [34-50|17]
[mmc]: [0-48|49] [54-56|3] [58-63|6]
[mmc]: [0-26|27] [54-63|10]
[mmc]: [0-58|59]
[mmc]: [6-51|46] [53-58|6]
[mmc]: [1-7|7] [9-56|48]
[mmc]: [1-26|26]
Normal
[6.618]MMC: 2
SUNXI SD/MMC: 2, SUNXI SD/MMC: 2
[6.624]sunxi flash init ok
[6.624]hdmi hdcp not enable!
Using default environment
[6.625]inter uboot shell
Hit any key to stop autoboot: 0
no mmc device at slot 0
mmc2(part 0) is current device
2512 bytes read in 5 ms (490.2 KiB/s)
## Executing script at 43100000
U-boot loaded from SD
Boot script loaded from mmc
** Bad device mmc 0 **
**** File not found /boot/dtb/sunxi/sun50i-h6-orangepi3.dtb **
fdt_valid fdt_check_header is -1271711085
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
fdt_valid fdt_check_header is -1271711085
libfdt fdt_check_header(): FDT_ERR_BADMAGIC**
8247895 bytes read in 404 ms (19.5 MiB/s)
19425352 bytes read in 945 ms (19.6 MiB/s)
## Booting kernel from Legacy Image at 41000000 ...
Image Name:
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 19425288 Bytes = 18.5 MiB
Load Address: 41000000
Entry Point: 41000000
Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 43300000 ...
Image Name: uInitrd
Image Type: ARM Linux RAMDisk Image (gzip compressed)
Data Size: 8247831 Bytes = 7.9 MiB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
Loading Kernel Image ... OK
reserving fdt memory region: addr=40020000 size=800
reserving fdt memory region: addr=48000000 size=1000000
reserving fdt memory region: addr=48100000 size=4000
reserving fdt memory region: addr=48104000 size=1000
reserving fdt memory region: addr=48105000 size=1000
reserving fdt memory region: addr=79ccb0e0 size=18f20
Loading Ramdisk to 49822000, end 49fffa17 ... OK
Using Device Tree in place at 44000000, end 4401d6bf
[8.736]disp_ioctl, display not init yet
[8.736]disp_ioctl, display not init yet
Starting kernel ...
INFO: BL3-1: Next image address = 0x41000000
INFO: BL3-1: Next image spsr = 0x3c5
WARNING: Unimplemented Standard Service Call: 0xc0000026
and the number fdt_check_headeris -804389139 id normol;
This why?
Why is the verification still correct in the front, but an error occurs in the back?
Have you ever encountered this problem? Or can you give me some advice? Thanks!
Are the report logs same when each reboot ?
If same, the DTB in hardware storage is fine.
And you should be concerned about memory overwriting between two fdt_magic function calls.
You're on 2014.07 which is missing both support for modern ext4 filesystem images as well as the warning / refusal to mount modern ext4 filesystem images that have features enabled by default that show symptoms such as "file I know exists, I can see it in Linux, are not found". Please upgrade to current U-Boot.

autohotkey soundset doesn't change mic

I'm trying to set my microphone to 50% with autohotkey but it only sets my master volume. I've tried
SoundSet 1, Microphone, 50
but it doesn't work. I also tried all the numbers up to 6.
I actually wrote something for this a while ago on the AHK subreddit. You can use this to toggle your mic volume to 50%. Pressing it again will set the volume back to whatever the original value was.
Give it a shot. If it doesn't work, let me know.
If it does, then you can mark your question answered.
Set your mic volume to something easy to remember but not common like 77. This is a temporary step to get the right audio device. You can change this later.
Run this script. PProvost wrote this and it can be found in the AHK Docs, too.
Look for the volume level that's set to 77. Note the component type (should look like Master:1), control type (most likely Volume or Microphone), and the mixer (which varies on each system. Mine was 10.)
;=============== Set This Stuff ===============
; Get this info from PProvost's script. If you lose the URL later, it's:
; https://github.com/PProvost/AutoHotKey/blob/master/SoundCardAnalysis.ahk
; Component Type
compType := "Master:1"
; Control Type
conType := "Volume"
; Mixer Number
mixer := 10
;Toggle tracker
toggle := 0
;=============== End "Set This Stuff" Section ===============
; Hotkey to set/toggle volume
F1::
; Tracks sound status
toggle = !toggle
; If toggle is turned on
if (toggle = 1){
; Save old setting
SoundGet, oldSound, % compType, % conType, % mixer
; Set new setting
SoundSet, 50, % compType, % conType, % mixer
; If toggle is off
}Else
; Revert to the old setting
SoundSet, % oldSound, % compType, % conType, % mixer
return
; Shift+Escape kills the app.
+Escape::ExitApp
I made my owm AHK with the response's help. I set it in my startup file and it sets my microphone volume to 30% every time I start up my computer (since my microphone is standard pretty loud)
Here is the code:
;=============== sauce ===============
; https://stackoverflow.com/questions/44330795/autohotkey-soundset-doesnt-change-mic
; https://github.com/PProvost/AutoHotKey/blob/master/SoundCardAnalysis.ahk
; Component Type
compType := "MASTER:1"
; Control Type
conType := "VOLUME"
; Mixer Number
mixer := 7
SoundSet, 31, % compType, % conType, % mixer

Bluez MediaEndpoint1 Timeout Issue When Replying To Dbus Call From Node Addon

Bluez Version: 5.43
Let me get straight to the point:
I have following error inside the Bluez log file:
Calling SetConfiguration: name = :1.3 path = /MediaEndpoint/A2DPSink
...
Endpoint replied with an error: org.freedesktop.DBus.Error.NoReply
If I change this line of code
#define REQUEST_TIMEOUT (3 * 1000) /* 3 seconds */
inside the ~/bluez-5.43/profiles/audio/media.c file,
to be a value greater, like 5 or so... The bug goes away.
So what is this bug?
basically, I have nodejs addon code that does the following:
Intialize endpoint
void endpoint_init(DBusConnection *connection, const char *endpoint) {
DBusObjectPathVTable vtable_endpoint;
vtable_endpoint.message_function = endpoint_handler;
dbus_connection_register_object_path(connection, endpoint, &vtable_endpoint, NULL);
}
Inside the Bluez log you will see bluetoothd[25176]: Endpoint registered: sender=:1.130 path=/MediaEndpoint/A2DPSink
The endpoint_handler function will be notified of a call to set_configuration or select_configuration function...
When a call is received, it will be be replied to like so...
sender = dbus_message_get_sender(m);
r = dbus_message_new_method_return(m);
printf("!! ----- endpoint_set_configuration, time_right_before_reply_sent: ");
print_time();
assert( dbus_connection_send(conn, r, NULL) );
dbus_connection_flush(conn);
printf("!! ----- endpoint_set_configuration, time_right_after_reply_sent: ");
print_time();
As you can see I am logging some time information.
Now, I also logged time information inside Bluez and recompiled it.
Here is log from Bluez:
bluetoothd[789]: profiles/audio/media.c:media_endpoint_async_call() Calling SetConfiguration: name = :1.3 path = /MediaEndpoint/A2DPSink
bluetoothd[789]: profiles/audio/media.c:endpoint_reply() [GOT HERE -- endpoint_reply -- original_msg --] SetConfiguration: name = :1.3 path = /MediaEndpoint/A2DPSink
bluetoothd[789]: profiles/audio/media.c:print_time() TIME BEFORE -- dbus_pending_call_steal_reply --: 2017-01-25 04:54:01
bluetoothd[789]: profiles/audio/media.c:print_time() TIME AFTER -- dbus_pending_call_steal_reply --: 2017-01-25 04:54:01
bluetoothd[789]: profiles/audio/media.c:endpoint_reply() [GOT HERE -- endpoint_reply -- reply_msg] (null): name = (null) path = (null)
bluetoothd[789]: Endpoint replied with an error: org.freedesktop.DBus.Error.NoReply
Here is log from my node addon:
endpoint_handler: path=/MediaEndpoint/A2DPSink, interface=org.bluez.MediaEndpoint1, member=SetConfiguration
!! ----- endpoint_set_configuration, endpoint_path: /MediaEndpoint/A2DPSink
!! ----- endpoint_set_configuration, time_right_before_reply_sent:
2017-01-25 04:54:03
!! ----- endpoint_set_configuration, time_right_after_reply_sent:
2017-01-25 04:54:03
You can CLEARLY see with the Bluez default timeout of 3 seconds is too short... the reply is still on its way...
But pulseaudio's implementation does not have this problem... why?
Is it because there are two different event loops, ie the node addon uses lib-uv event loop and Bluez and pulse use the glib event loop...
What is going on here, can anyone please explain.
I would prefer to either identify it as Bluez bug or understand how to fix it on my node addon end...
Thank You Stackoverflowers :)
P.S.
Bluez ~/bluez-5.43/profiles/audio/media.c has code that advises to keep the REQUEST_TIMEOUT at 3, this worries me...
/* Timeout should be less than avdtp request timeout (4 seconds) */
if (g_dbus_send_message_with_reply(btd_get_dbus_connection(),
msg, &request->call,
REQUEST_TIMEOUT) == FALSE) {
error("D-Bus send failed");
g_free(request);
return FALSE;
}
I found that there is some conflict with the glib and libuv running together under the same process..
the node-dbus addon i am using is a c level binding and it instantiates a glib event loop...
nodejs has a libuv event loop
they dont work well together...
this is what i can assume the problem is..
my solution was to rip the c code from bluez media enpoint and i created my own nodejs NAN bindings to it...without using any glib event loop.
this is the node-dbus library i am using:
https://github.com/Shouqun/node-dbus

TinyX shows display using builtin fbtft touchscreen driver but touch doesn't work

I'm using an "adafruitts" touchscreen with a raspi to control a usb peripheral.
The full raspbian kernel takes forever to boot (50 seconds), and part of that is due to the touchscreen driver loading (by modprobe/udev) and initializing.
During the first 20-30 seconds of boot, the display is not loaded, so it is blank. I need this to be a user-friendly item that cannot be blank for 30 seconds each time it is turned on, so I've used buildroot to build a small kernel with the touchscreen driver built-in. (I am on a steep learning curve with buildroot and kernel building in general).
The display driver is fbtft_device.c patched to include the adafruitts display. This patch defines the "touch" half:
/* Touch device spi-half of adafruit touchscreen */
.name = "adafruitts",
.spi = &(struct spi_board_info) {
.modalias = "stmpe610",
.max_speed_hz = 500000,
.mode = SPI_MODE_0,
.chip_select = 1,
.platform_data = &(struct stmpe_platform_data) {
.blocks = STMPE_BLOCK_TOUCHSCREEN | STMPE_BLOCK_GPIO,
.irq_over_gpio = 1,
.irq_gpio = 24,
.irq_trigger = IRQF_TRIGGER_FALLING,
.irq_base = GPIO_IRQ_START + GPIO_IRQS,
.ts = &(struct stmpe_ts_platform_data) {
.sample_time = 4,
.mod_12b = 1,
.ref_sel = 0,
.adc_freq = 2,
.ave_ctrl = 3,
.touch_det_delay = 4,
.settling = 2,
.fraction_z = 7,
.i_drive = 0,
},
}
},
.is_support = 1,
.gpio_settings = (struct gpio_setting []) {
{
.gpio = 24,
.pull = pull_up,
}
},
.gpio_num_settings = 1,
},
and the LCD half:
}, {
/* LCD component of adafruit touchscreen */
.name = "adafruitts",
.spi = &(struct spi_board_info) {
.modalias = "fb_ili9340",
.max_speed_hz = 16000000,
.mode = SPI_MODE_0,
.chip_select = 0,
.platform_data = &(struct fbtft_platform_data) {
.display = {
.buswidth = 8,
.backlight = 1,
},
.bgr = true,
.gpios = (const struct fbtft_gpio []) {
{ "dc", 25 },
{},
},
}
}
}, {
by including:
fbtft_device.name=adafruitts
in the cmdline.txt for the boot loader, I've gotten the display half of the system to work (it boots in ~ 5 seconds :) ) with tinyX/matchbox desktop showing the desktop, but I cannot get the touchscreen part to work (the cursor does not move when I touch the screeen).
Somehow I have to bind the touch part of the touchscreen to tinyX, but I have not been able to figure out how to do this.
I have tried to specify the keyboard (and mouse) when launching tinyX:
X -keybd smpte610 (for example)
but X reports it cannot find the driver.
How can I verify the touch screen input device was successfully loaded?
The boot log has these messages about fbtft_device:
fbtft_device: SPI devices registered:
fbtft_device: spidev spi0.0 500kHz 8 bits mode=0x00
fbtft_device: spidev spi0.1 500kHz 8 bits mode=0x00
fbtft_device: 'fb' Platform devices registered:
fbtft_device: bcm2708_fb id=-1 pdata? no
fbtft_device: Deleting spi0.1 (spi0.1)
fbtft_device: Looking at item 0
fbtft_device: Setting pin 24 to 2
stmpe-spi: probe of spi0.1 failed with error -22
fbtft_device: Deleting spi0.0 (spi0.0)
Console: switching to colour frame buffer device 40x30
graphics fb0: fb_ili9340 frame buffer, 320x240, 150 KiB video memory, 16 KiB buffer memory, fps=20, spi0.0 at 16 MHz
fbtft_device: GPIOS used by 'adafruitts':
fbtft_device: 'dc' = GPIO25
fbtft_device: SPI devices registered:
fbtft_device: stmpe610 spi0.1 48000kHz 8 bits mode=0x00
fbtft_device: fb_ili9340 spi0.0 16000kHz 8 bits mode=0x00
kgdb: Registered I/O driver kgdboc.
Is the kgdb message associated with fbtft_device or something else?
If I look in /dev/input I see: event0, event1, and mice. event0 and event1 are associated with an attached keyboard (according to the boot log) and I have no mouse attached. Should there be some other items in input?
If the touch screen input device IS loaded, how to I specify the correct driver for tinyX?
Thanks
What I learned:
By comparing the boot messages in my modprobe/udev/module loading kernel with the fast built-in kernel, it shows:
stmpe-spi: probe of spi0.1 failed with error -22
is a "bad" thing.
A successful driver load will say (something like):
bcm2708_spi.0: registered child spi0.0
and then later:
input: stmpe-ts as /devices/virtual/input/input0
I fixed the "probe" failure by making these changes to my kernel configuration file. (Sorry, I don't want to include the whole thing, so these are the changes from when I had the issue to when the driver successfully loaded according to the syslog):
< Touch Did Not respond > Touch Did respond
> CONFIG_INPUT_FF_MEMLESS=y
< CONFIG_INPUT_POLLDEV=m > CONFIG_INPUT_POLLDEV=y
< CONFIG_INPUT_EVDEV=m > CONFIG_INPUT_EVDEV=y
< CONFIG_TOUCHSCREEN_STMPE=m > CONFIG_TOUCHSCREEN_STMPE=y
> CONFIG_KEYBOARD_STMPE=y
< CONFIG_SERIO=m > CONFIG_SERIO_SERPORT=m
> CONFIG_SPI_DEBUG=y
< CONFIG_SPI_SPIDEV=y
> CONFIG_SPI_GPIO=y
My main objective with these changes was to try to make sure that the dependent drivers were also built-in, and I enabled the debug. (Some of these were magically set by menuconfig, and this is diff from the "non-default" values from buildroot, so the diff is - different)
With this config, I now have event0, event1, event2, mice, and mouse0. The syslog says event1 and event2 are associated with the usb keyboard I have attached. I have no extra mouse attached.
I could use "evtest" to see events from /dev/input/event0 whenever I touched the display. evtest'ing /dev/input/mouse0 threw "Inappropriate ioctl for device"
I restarted X (tinyX) using:
X -mouse mouse,,/dev/input/mouse0
and touches worked, but the touch axis is rotated from the display axis.
I could not figure out a way to fix this in tinyX, so I'm going with a full blown Xorg implementation.
Make sure you have enabled the evdev input support in tinyx (BR2_PACKAGE_XSERVER_XORG_SERVER_KDRIVE_EVDEV) and use the syntax specified in hw/kdrive/src/kinput.c:
/*
* You can call your kdriver server with something like:
* $ ./hw/kdrive/yourserver/X :1 -mouse evdev,,device=/dev/input/event4 -keybd
* evdev,,device=/dev/input/event1,xkbmodel=abnt2,xkblayout=br
*/

can't get the mouse move event from /dev/input/event*

I can't get the mouse move event when using the evtest tools to test the input events .
I just get three mouse events:
left click event: type = EV_KEY, code = 272 (LeftBtn), value=1/0
right click event: type = EV_KEY, code = 273 (RightBtn), value = 1/0
mouse wheel event: type = EV_REL, code = 8 (Wheel), value = -1
No mouse move event. So where my mouse move event and how to capture it?
ps: Tested on Ubuntu 11.04 and Gentoo in VirtualBox-4 with virtualBox-addition installed.
If not on an embedded linux system I prefer to use the input-utils tools rather than evtest (and if I'm on Android I use cat /proc/bus/input/devices and getevent )
Install input-utils via:
$ sudo apt-get install input-utils
List all my input devices
$ sudo lsinput
/dev/input/event0
bustype : BUS_HOST
vendor : 0x0
product : 0x5
version : 0
name : "Lid Switch"
..
..
phys : "isa0060/serio1/input0"
bits ev : EV_SYN EV_KEY EV_ABS
/dev/input/event12
bustype : BUS_I8042
vendor : 0x2
product : 0xa
version : 0
name : "TPPS/2 IBM TrackPoint"
phys : "synaptics-pt/serio0/input0"
bits ev : EV_SYN EV_KEY EV_REL
Then I read events on my laptop's trackpoint (don't forget to move the it around after starting input-events)
$ sudo input-events 12
/dev/input/event12
bustype : BUS_I8042
vendor : 0x2
product : 0xa
version : 0
name : "TPPS/2 IBM TrackPoint"
phys : "synaptics-pt/serio0/input0"
bits ev : EV_SYN EV_KEY EV_REL
waiting for events
16:43:46.516075: EV_REL REL_Y -1
16:43:46.516090: EV_SYN code=0 value=0
16:43:46.539642: EV_REL REL_X -1
16:43:46.539656: EV_REL REL_Y -1
16:43:46.539660: EV_SYN code=0 value=0
16:43:46.704385: EV_REL REL_Y -1
16:43:46.704401: EV_SYN code=0 value=0
Have you tried actually moving the mouse rather than evtest?
I don't get anything on /dev/input/event* when I move my mouse but do on /dev/input/by-path/platform-i8042-serio-1-event-mouse. I also don't get anything when I use /dev/input/by-path/platform-i8042-serio-1-event-mouse and move the mouse across Synergy, I have to physically move the mouse.
Sach

Resources