notro / fbtft

Linux Framebuffer drivers for small TFT LCD display modules. Development has moved to https://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/tree/drivers/staging/fbtft?h=staging-testing
1.84k stars 495 forks source link

system stucks when using fbtftops.write() to transfer data #566

Closed xray-bit closed 3 years ago

xray-bit commented 3 years ago

I wrote this with reference to fb_ssd1306.c

fb_xxx.c

static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
{
    u16 *vmem16 = (u16 *)par->info->screen_buffer;
    u8 *buf = par->txbuf.buf;
    u8 *p_buf = par->txbuf.buf;
    int x, y, i;
    int ret = 0;
    int j;

    for (y = 0; y < 8; y++) {
        for (x = 0; x < 128; x++) {
            *buf = 0x00;
            for (i = 0; i < 8; i++) {
                if (vmem16[(y * 8 + i) * 128 + x])
                    *buf |= BIT(i);
            }
            buf++;
        }
    }

    /* Write data */
    for (j = 0; j < 8; j++)
    {
        set_page(j); //set page address
        gpiod_set_value(par->gpio.dc, 1);
        par->fbtftops.write(par, p_buf, 128);
        p_buf += 128;
    }
    return ret;
}

message after insmod fb_xxx

spi spi2.0: fb_st7571 spi2.0 500kHz 8 bits mode=0x00
fb_st7571: module is from the staging directory, the quality is unknown, you have been warned.
fb_st7571 spi2.0: fbtft_gamma_parse_str() str=
fb_st7571 spi2.0: 10
fb_st7571 spi2.0: fbtft_request_gpios: 'reset' = GPIO34
fb_st7571 spi2.0: fbtft_request_gpios: 'dc' = GPIO32
fb_st7571 spi2.0: fbtft_request_gpios: 'led' = GPIO33
fb_st7571 spi2.0: fbtft_verify_gpios()
fb_st7571 spi2.0: init_display()
fb_st7571 spi2.0: fbtft_reset()
fb_st7571 spi2.0: set_var()
fb_st7571 spi2.0: fbtft_update_display(start_line=0, end_line=127)

and system will stuck here forever.

xray-bit commented 3 years ago

I found those in fbtft-core.c: https://github.com/notro/fbtft/blob/354cbeba1282a9e73dfc90bfe309a874610d7a19/fbtft-core.c#L863-L874

it works fine if I disable dma or allocate another dev memory.
problem solved.
thx :)