Skip to content

Commit 706a184

Browse files
committed
in fbtft-io Critical section, to reset and set spi msg struct
1 parent 95c88d8 commit 706a184

File tree

4 files changed

+45
-28
lines changed

4 files changed

+45
-28
lines changed

arch/arm/boot/dts/sun8i-v3s-funkey.dts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@
190190
buswidth = <8>;
191191
reset-gpios = <&pio 1 2 GPIO_ACTIVE_HIGH>; //PB2
192192
dc-gpios = <&pio 2 0 GPIO_ACTIVE_LOW>; //PC0 (MISO)
193-
te-irq = <&pio 1 1 GPIO_ACTIVE_LOW>; //PB1
194193
debug = <0>;
194+
te-irq = <&pio 1 1 GPIO_ACTIVE_LOW>; //PB1
195195
};
196196
};
197197

drivers/staging/fbtft/fbtft-bus.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,20 @@ int fbtft_start_new_screen_transfer_async(struct fbtft_par *par)
143143

144144
if (par->nb_fps_values == 200) {
145145
fbtft_par_dbg(DEBUG_TIME_EACH_UPDATE, par,
146-
"Display update: fps=%ld\n", par->avg_fps / par->nb_fps_values);
146+
"Display update%s: fps=%ld\n",
147+
par->pdata->te_irq_enabled?" (TE)":"",
148+
par->avg_fps / par->nb_fps_values);
149+
printk("Display update%s: fps=%ld\n",
150+
par->pdata->te_irq_enabled?" (TE)":"",
151+
par->avg_fps / par->nb_fps_values);
147152
par->avg_fps = 0;
148153
par->nb_fps_values = 0;
149154
}
150155
}
151156

152157
#endif //FPS_DEBUG
153158

154-
/* Post process screen for doufle buf cpy, notifs, rotation soft... */
159+
/* Post process screen for doufle buf copy, notifs, rotation soft... */
155160
fbtft_post_process_screen(par);
156161

157162
/* new line to write */
@@ -256,17 +261,17 @@ static void spi_complete_cmd_init_data_write(void *arg)
256261

257262
int fbtft_write_init_cmd_data_transfers(struct fbtft_par *par)
258263
{
259-
static u8 init_data_cmd_buf = MIPI_DCS_WRITE_MEMORY_START;
264+
static const u8 init_data_cmd_buf = MIPI_DCS_WRITE_MEMORY_START;
260265
int ret = 0;
261266

262267
// printk("%s\n", __func__);
263268

264-
/* Resetting to 0 for incoming cmd init data write */
269+
/* Resetting to 0 for incoming cmd: "init data write" */
265270
if (gpio_is_valid(par->gpio.dc))
266271
gpio_set_value(par->gpio.dc, 0);
267272

268273
/* Start sending cmd init data */
269-
ret = par->fbtftops.write_async(par, &init_data_cmd_buf, 1,
274+
ret = par->fbtftops.write_async(par, (u8 *) &init_data_cmd_buf, 1,
270275
spi_complete_cmd_init_data_write);
271276
if (ret < 0)
272277
dev_err(par->info->device, "write() failed and returned %d\n", ret);
@@ -351,7 +356,8 @@ int fbtft_write_vmem16_bus8_async(struct fbtft_par *par, size_t offset, size_t l
351356
startbyte_size = 1;
352357
}
353358

354-
while (remain) {
359+
/* No while here, must be one shot */
360+
//while (remain) {
355361
to_copy = min(tx_array_size, remain);
356362
dev_dbg(par->info->device, " to_copy=%zu, remain=%zu\n",
357363
to_copy, remain - to_copy);
@@ -360,12 +366,12 @@ int fbtft_write_vmem16_bus8_async(struct fbtft_par *par, size_t offset, size_t l
360366
txbuf16[i] = cpu_to_be16(vmem16[i]);
361367

362368
vmem16 = vmem16 + to_copy;
363-
ret = par->fbtftops.write_async(par, par->txbuf.buf,
369+
ret = par->fbtftops.write_async(par, (u8 *) par->txbuf.buf,
364370
startbyte_size + to_copy * 2, spi_complete_data_write);
365371
if (ret < 0)
366372
return ret;
367373
remain -= to_copy;
368-
}
374+
//}
369375

370376
return ret;
371377
}

drivers/staging/fbtft/fbtft-core.c

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -582,24 +582,27 @@ void fbtft_post_process_screen(struct fbtft_par *par)
582582

583583
/* Copy buffer */
584584

585-
/* This should be handled using a double buffer (or
586-
triple depending on game fps vs screen fps) pointed
587-
by par->info->screen_buffer. The buffer pointed
588-
(the one being written) should change using the
589-
FBIOPAN_DISPLAY ioctl called by SDL_Flip() (in
590-
FB_FlipHWSurface). This is a dirty but very
591-
efficient alternative for now: we make a quick
592-
memcpy of the screen_buffer in another one. It goes
593-
so fast that the "applicative" tearing that could
594-
happen if this function were to launch in the
595-
middle of a user space SDL_BlitSurface(sw_surface,
596-
NULL, hw_surface, NULL) call is so unbelievably
597-
rare that completey unnoticeable and it takes up so
598-
little CPU that really, it's worth the compromise
599-
for now */
585+
/*
586+
This should be handled using a double buffer (or
587+
triple depending on game fps vs screen fps) pointed
588+
by par->info->screen_buffer. The buffer pointed
589+
(the one being written) should change using the
590+
FBIOPAN_DISPLAY ioctl called by SDL_Flip() (in
591+
FB_FlipHWSurface). This is a dirty but very
592+
efficient alternative for now: we make a quick
593+
memcpy of the screen_buffer in another one. It goes
594+
so fast that the "applicative" tearing that could
595+
happen if this function were to launch in the
596+
middle of a user space SDL_BlitSurface(sw_surface,
597+
NULL, hw_surface, NULL) call is rare enough not to
598+
be noticed much and it takes up so little CPU that
599+
really, it's worth the compromise for now
600+
*/
601+
//printk("m\n");
600602
memcpy(par->vmem_post_process + par->write_line_start * par->info->fix.line_length,
601603
par->info->screen_buffer + par->write_line_start * par->info->fix.line_length,
602604
(par->write_line_end-par->write_line_start + 1) * par->info->fix.line_length);
605+
//printk("n\n");
603606

604607
/* Notifications */
605608
if (par->notification[0]) {
@@ -634,7 +637,7 @@ static void fbtft_deferred_io(struct fb_info *info, struct list_head *pagelist)
634637
unsigned long index;
635638
unsigned int y_low = 0, y_high = 0;
636639
int count = 0;
637-
640+
638641
//#define FPS_DEBUG
639642
#if 0
640643
long fps;
@@ -1336,7 +1339,7 @@ int fbtft_register_framebuffer(struct fb_info *fb_info)
13361339
fb_info->fix.id, fb_info->var.xres, fb_info->var.yres,
13371340
fb_info->fix.smem_len >> 10, text1,
13381341
HZ / fb_info->fbdefio->delay, text2,
1339-
par->spi_async_mode ? "SPI mode asynchrone, " : "",
1342+
par->spi_async_mode ? "SPI mode async, " : "",
13401343
par->interlacing ? "Interlaced" : "");
13411344

13421345
#ifdef CONFIG_FB_BACKLIGHT
@@ -1864,10 +1867,12 @@ int fbtft_probe_common(struct fbtft_display *display,
18641867
/* Start constant Display update using spi async */
18651868
par->write_line_start = 0;
18661869
par->write_line_end = par->info->var.yres - 1;
1867-
if (par->pdata->te_irq_enabled)
1870+
if (par->pdata->te_irq_enabled){
18681871
par->ready_for_spi_async = true;
1869-
else
1872+
}
1873+
else{
18701874
fbtft_start_new_screen_transfer_async(par);
1875+
}
18711876
}
18721877
return 0;
18731878

drivers/staging/fbtft/fbtft-io.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <linux/errno.h>
44
#include <linux/gpio.h>
55
#include <linux/spi/spi.h>
6+
#include <linux/spinlock.h>
67
#include "fbtft.h"
78

89
/* Ugly static declarations for now */
@@ -31,10 +32,15 @@ int fbtft_write_spi_async(struct fbtft_par *par, void *buf, size_t len, void (*
3132
return -1;
3233
}
3334

35+
/** Critical section, to reset and set spi msg struct */
36+
spin_lock(&par->dirty_lock);
37+
3438
spi_message_init(m);
3539
m->complete = cb;
3640
m->context = par;
3741
spi_message_add_tail(t, m);
42+
43+
spin_unlock(&par->dirty_lock);
3844

3945
return spi_async(par->spi, m);
4046
#endif

0 commit comments

Comments
 (0)