1.1 --- a/pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc Sat Jun 13 21:07:58 2020 +0200
1.2 +++ b/pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc Tue Jun 16 23:24:32 2020 +0200
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Common LCD device support for the JZ4740 and related SoCs.
1.6 *
1.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2018, 2020 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -22,6 +22,7 @@
1.13 #include <l4/devices/cpm-client.h>
1.14 #include <l4/devices/display-client.h>
1.15 #include <l4/devices/lcd-jz4740.h>
1.16 +#include <l4/devices/lcd-jz4780.h>
1.17 #include <l4/devices/panel-loader.h>
1.18 #include <l4/devices/memory.h>
1.19 #include "lcd-jz4740-device.h"
1.20 @@ -88,16 +89,24 @@
1.21 {
1.22 Lcd_jz4740_chip *chip = static_cast<Lcd_jz4740_chip *>(_chip);
1.23
1.24 + // Initialise the clocks for the LCD controller. Without this, the controller
1.25 + // cannot be operated.
1.26 +
1.27 + set_timing();
1.28 +
1.29 + // Configure the controller.
1.30 +
1.31 chip->disable();
1.32 chip->config((struct Jz4740_lcd_descriptor *) desc_vaddr,
1.33 (struct Jz4740_lcd_descriptor *) desc_paddr,
1.34 fb_paddr);
1.35
1.36 - // Initialise the clocks for the LCD controller.
1.37 + // Activate the display channel.
1.38
1.39 - set_timing();
1.40 enable_display();
1.41
1.42 + // Activate the controller output.
1.43 +
1.44 chip->enable();
1.45 }
1.46
1.47 @@ -141,10 +150,12 @@
1.48
1.49 // Allocate memory for the framebuffer at 2**6 == 64 byte == 16 word alignment,
1.50 // also for the descriptors.
1.51 + // NOTE: A 64 word burst mode is available on the JZ4780 that would
1.52 + // NOTE: necessitate 64 word alignment for the framebuffer.
1.53
1.54 const l4_size_t alloc_flags = L4Re::Mem_alloc::Continuous | L4Re::Mem_alloc::Pinned;
1.55
1.56 - if (L4Re::Env::env()->mem_alloc()->alloc(fb_size, _fbmem, alloc_flags, 6) ||
1.57 + if (L4Re::Env::env()->mem_alloc()->alloc(fb_size, _fbmem, alloc_flags, 8) ||
1.58 L4Re::Env::env()->mem_alloc()->alloc(desc_size, descmem, alloc_flags, 6))
1.59 return 1;
1.60
1.61 @@ -197,6 +208,15 @@
1.62
1.63 switch (panel->bpp)
1.64 {
1.65 + // NOTE: 24bpp here is actually RGBA or RGB padded.
1.66 +
1.67 + case 24:
1.68 + view_info->pixel_info.bytes_per_pixel = 4;
1.69 + view_info->pixel_info.r.shift = 16; view_info->pixel_info.r.size = 8;
1.70 + view_info->pixel_info.g.shift = 8; view_info->pixel_info.g.size = 8;
1.71 + view_info->pixel_info.b.shift = 0; view_info->pixel_info.b.size = 8;
1.72 + break;
1.73 +
1.74 case 32:
1.75 view_info->pixel_info.r.shift = 16; view_info->pixel_info.r.size = 8;
1.76 view_info->pixel_info.g.shift = 8; view_info->pixel_info.g.size = 8;
1.77 @@ -231,8 +251,15 @@
1.78
1.79 static int setup_memory()
1.80 {
1.81 + bool is_jz4780 = false;
1.82 +
1.83 if (get_memory("jz4740-lcd", &lcd_virt_base, &lcd_virt_base_end))
1.84 - return 1;
1.85 + {
1.86 + if (get_memory("jz4780-lcd", &lcd_virt_base, &lcd_virt_base_end))
1.87 + return 1;
1.88 + else
1.89 + is_jz4780 = true;
1.90 + }
1.91
1.92 // Obtain access to the CPM and display devices.
1.93
1.94 @@ -248,7 +275,10 @@
1.95
1.96 // Initialise the LCD abstraction.
1.97
1.98 - lcd_chip = new Lcd_jz4740_chip(lcd_virt_base, panel);
1.99 + if (is_jz4780)
1.100 + lcd_chip = new Lcd_jz4780_chip(lcd_virt_base, panel);
1.101 + else
1.102 + lcd_chip = new Lcd_jz4740_chip(lcd_virt_base, panel);
1.103
1.104 return 0;
1.105 }