简体   繁体   中英

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 */

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM