Closed tomsn1978 closed 1 year ago
you can modify the init sequence in fb_ssd1305.c
I have a single color screen model UC1618, which is similar to UC1701. I wrote a driver after fb_uc1701.c, which displays normally. Now I use qt to draw the screen pattern, where the color 0xFFFFFF means white, The color conversion in the "write_vmem" function also runs when the driver is loaded. When the module is loaded the data in the par->info->screen_buffer is 0x00, so it shows black. I think when initializing, par->info->screen_buffer is initialized to 0xff, which is 0xFF when the memory space is requested
I can't see anything in fbtft/driver that should initialize the screen buffer to 0xff. I suggest you turn on debug output to see what is going on.
static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
{
//dump_stack();
u16 *vmem16 = (u16 *)par->info->screen_buffer;
u8 *buf;
int x, y, i;
int ret = 0;
for (y = 0; y < PAGES; y++) {
buf = par->txbuf.buf;
for (x = 0; x < WIDTH; x++) {
*buf = 0x00;
for (i = 0; i < 8; i++)
{
*buf |= (vmem16[((y * 8 * WIDTH) + (i * WIDTH)) + x]!=0xFFFF ? 1 : 0)<< i;
}
buf++;
}
gpio_set_value(par->gpio.dc, 1);
ret = par->fbtftops.write(par, par->txbuf.buf, WIDTH);
gpio_set_value(par->gpio.dc, 0);
}
}
"I used 'dump_stack()' to trace the call stack when the kernel loads this module, and found that the 'write_vmem' function was called during kernel startup. I believe that somewhere in the code where it is used, a u16 vmem16 = (u16 )par->info->screen_buffer; was initialized as 0x00. Now I want to initialize it to 0xff."
Please post the dump_stack() output.
[ 2.177186] fbtft_of_value: buswidth = 8
[ 2.181288] fbtft_of_value: debug = 0
[ 2.184990] fbtft_of_value: rotate = 0
[ 2.188779] fbtft_of_value: fps = 40
[ 2.322545] CPU: 0 PID: 1 Comm: swapper Not tainted 4.19.94-gbe5389fd85 #64
[ 2.329577] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 2.335770] Backtrace:
[ 2.338275] [
This is the log at kernel startup time
**[ 21.033722] CPU: 0 PID: 771 Comm: kworker/0:3 Not tainted 4.19.94-gbe5389fd85 #64
[ 21.041402] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 21.047590] Workqueue: events fb_deferred_io_work
[ 21.052452] Backtrace:
[ 21.054968] [
** This is the log that is refreshed normally on the screen
They both call "write_vmem", and the data in par->info->screen_buffer is initialized to 0x00 when the kernel is started, and par->info->screen_buffer data is provided by the application layer when it is displayed normally
This is strange, so if I understand you correctly when write_vmem() is called the first time the buffer constains 0xff. And you have checked that the buffer is 0x00 on allocation in fbtft_framebuffer_alloc(). I would have checked the buffer at various points following the call chain to find at which point it changes to 0xff.
"When write_vmem() is called for the first time, the buffer is constrained to 0x00. I want to initialize this buffer to 0xFF."
Oh, ok.
You could use the Set Inverse Display
command:
Set DC[0] to force all SEG drivers to output the inverse of the data stored in display memory. This function
has no effect on the existing data stored in display RAM.
Or you could add memset(par->info->screen_buffer, 0xff, par->info->fix.smem_len)
in init_display().
Thank you. I have been looking for the right place to use memset(par->info->screen_buffer, 0xff, par->info->fix.smem_len)
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.
Hi I have a monochrome screen and I want to initialize the screen to black when I boot the kernel. Where should I modify the source code