1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/conf/landfall-examples/mips-ci20-common.io Tue Jun 16 23:24:32 2020 +0200 1.3 @@ -0,0 +1,25 @@ 1.4 +-- vim: ft=lua ts=2 et sw=2 1.5 + 1.6 +-- Configuration file for Io. 1.7 + 1.8 +local hw = Io.system_bus() 1.9 + 1.10 +Io.add_vbus("cpm", Io.Vi.System_bus 1.11 +{ 1.12 + CPM = wrap(hw:match("jz4780-cpm")); 1.13 +}) 1.14 + 1.15 +Io.add_vbus("gpio", Io.Vi.System_bus 1.16 +{ 1.17 + GPIO = wrap(hw:match("jz4780-gpio")); 1.18 +}) 1.19 + 1.20 +Io.add_vbus("lcd", Io.Vi.System_bus 1.21 +{ 1.22 + LCD = wrap(hw:match("jz4780-lcd")); 1.23 +}) 1.24 + 1.25 +Io.add_vbus("hdmi", Io.Vi.System_bus 1.26 +{ 1.27 + HDMI = wrap(hw:match("jz4780-hdmi")); 1.28 +})
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/conf/landfall-examples/mips-ci20-fbdrv.cfg Tue Jun 16 23:24:32 2020 +0200 2.3 @@ -0,0 +1,70 @@ 2.4 +-- vim: ft=lua ts=2 et sw=2 2.5 + 2.6 +-- Start the framebuffer driver with supporting devices. 2.7 +-- The target platform is the MIPS Creator CI20. 2.8 + 2.9 +local L4 = require("L4"); 2.10 + 2.11 +local l = L4.default_loader; 2.12 + 2.13 +-- Define general access to peripherals. 2.14 + 2.15 +local io_buses = { 2.16 + cpm = l:new_channel(); 2.17 + gpio = l:new_channel(); 2.18 + hdmi = l:new_channel(); 2.19 + lcd = l:new_channel(); 2.20 + }; 2.21 + 2.22 +l:start({ 2.23 + caps = { 2.24 + cpm = io_buses.cpm:svr(), 2.25 + gpio = io_buses.gpio:svr(), 2.26 + hdmi = io_buses.hdmi:svr(), 2.27 + lcd = io_buses.lcd:svr(), 2.28 + 2.29 + icu = L4.Env.icu, 2.30 + sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0), 2.31 + }, 2.32 + }, 2.33 + "rom/io rom/hw_devices.io rom/mips-ci20-common.io"); 2.34 + 2.35 +-- Expose the CPM peripheral. 2.36 + 2.37 +local cpm = l:new_channel(); 2.38 + 2.39 +l:start({ 2.40 + caps = { 2.41 + vbus = io_buses.cpm, 2.42 + cpm = cpm:svr(), 2.43 + }, 2.44 + }, 2.45 + "rom/dev_cpm_jz4780"); 2.46 + 2.47 +-- Expose a display device for the CI20. 2.48 + 2.49 +local display = l:new_channel(); -- exposes display device 2.50 + 2.51 +l:start({ 2.52 + caps = { 2.53 + cpm = cpm, 2.54 + display = display:svr(), 2.55 + icu = L4.Env.icu, 2.56 + vbus = io_buses.hdmi, -- for HDMI resource access 2.57 + }, 2.58 + }, 2.59 + "rom/dev_display_ci20_hdmi"); 2.60 + 2.61 +-- Expose a framebuffer device. 2.62 + 2.63 +local fbdrv_fb = l:new_channel(); 2.64 + 2.65 +l:start({ 2.66 + caps = { 2.67 + vbus = io_buses.lcd, 2.68 + fb = fbdrv_fb:svr(), 2.69 + cpm = cpm, 2.70 + display = display, -- needed by LCD driver 2.71 + }, 2.72 + }, 2.73 + "rom/fb-drv");
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/conf/landfall-examples/mips-ci20-fbdrv.list Tue Jun 16 23:24:32 2020 +0200 3.3 @@ -0,0 +1,18 @@ 3.4 + 3.5 +modaddr 0x1100000 3.6 + 3.7 +entry mips-ci20-fbdrv-example 3.8 +bootstrap bootstrap -serial 3.9 +kernel fiasco -serial_esc 3.10 +roottask moe rom/mips-ci20-fbdrv.cfg 3.11 +module mips-ci20-fbdrv.cfg 3.12 +module mips-ci20-common.io 3.13 +module plat-mips-ci20/hw_devices.io 3.14 +module l4re 3.15 +module io 3.16 +module ned 3.17 +module fb-drv 3.18 +module dev_display_ci20_hdmi 3.19 +module dev_cpm_jz4780 3.20 +module libpanel_ci20.so 3.21 +module mips-jz4740-panel.txt
4.1 --- a/pkg/devices/Control Sat Jun 13 21:07:58 2020 +0200 4.2 +++ b/pkg/devices/Control Tue Jun 16 23:24:32 2020 +0200 4.3 @@ -3,6 +3,7 @@ 4.4 provides: devices-cpm-jz4730 4.5 provides: devices-cpm-jz4740 4.6 provides: devices-cpm-jz4780 4.7 +provides: devices-display-ci20_hdmi 4.8 provides: devices-display-letux400 4.9 provides: devices-display-qi_lb60 4.10 provides: devices-fb-jz4740 4.11 @@ -42,6 +43,7 @@ 4.12 provides: libdrivers-keypad-qi_lb60 4.13 provides: libdrivers-lcd-headers 4.14 provides: libdrivers-lcd-jz4740 4.15 +provides: libdrivers-panel-ci20 4.16 provides: libdrivers-panel-headers 4.17 provides: libdrivers-panel-letux400 4.18 provides: libdrivers-panel-loader
5.1 --- a/pkg/devices/Makefile Sat Jun 13 21:07:58 2020 +0200 5.2 +++ b/pkg/devices/Makefile Tue Jun 16 23:24:32 2020 +0200 5.3 @@ -11,7 +11,7 @@ 5.4 5.5 backlight: pwm spi 5.6 cpm: lib util 5.7 -display: backlight lib util 5.8 +display: backlight cpm lib util 5.9 fb: lcd lib util 5.10 input: keypad lib 5.11 keypad: lib util
6.1 --- a/pkg/devices/cpm/include/cpm-client.h Sat Jun 13 21:07:58 2020 +0200 6.2 +++ b/pkg/devices/cpm/include/cpm-client.h Tue Jun 16 23:24:32 2020 +0200 6.3 @@ -1,7 +1,7 @@ 6.4 /* 6.5 * CPM client to access CPM servers. 6.6 * 6.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 6.8 + * Copyright (C) 2018, 2020 Paul Boddie <paul@boddie.org.uk> 6.9 * 6.10 * This program is free software; you can redistribute it and/or 6.11 * modify it under the terms of the GNU General Public License as 6.12 @@ -31,9 +31,17 @@ 6.13 L4_KOBJECT(Cpm_device_interface) 6.14 6.15 public: 6.16 + int get_lcd_pixel_frequency(uint32_t *frequency) throw(); 6.17 + 6.18 + int set_hdmi_frequency(uint32_t frequency) throw(); 6.19 int set_lcd_frequencies(uint32_t pclk, uint8_t multiplier) throw(); 6.20 + 6.21 + int start_hdmi() throw(); 6.22 + int stop_hdmi() throw(); 6.23 + 6.24 int start_lcd() throw(); 6.25 int stop_lcd() throw(); 6.26 + 6.27 int update_output_frequency() throw(); 6.28 }; 6.29
7.1 --- a/pkg/devices/cpm/include/cpm-ops.h Sat Jun 13 21:07:58 2020 +0200 7.2 +++ b/pkg/devices/cpm/include/cpm-ops.h Tue Jun 16 23:24:32 2020 +0200 7.3 @@ -1,7 +1,7 @@ 7.4 /* 7.5 * CPM server operations. 7.6 * 7.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 7.8 + * Copyright (C) 2018, 2020 Paul Boddie <paul@boddie.org.uk> 7.9 * 7.10 * This program is free software; you can redistribute it and/or 7.11 * modify it under the terms of the GNU General Public License as 7.12 @@ -26,4 +26,8 @@ 7.13 Cpm_op_start_lcd, 7.14 Cpm_op_stop_lcd, 7.15 Cpm_op_update_output_frequency, 7.16 + Cpm_op_get_lcd_pixel_frequency, 7.17 + Cpm_op_set_hdmi_frequency, 7.18 + Cpm_op_start_hdmi, 7.19 + Cpm_op_stop_hdmi, 7.20 };
8.1 --- a/pkg/devices/cpm/src/client/cpm-client.cc Sat Jun 13 21:07:58 2020 +0200 8.2 +++ b/pkg/devices/cpm/src/client/cpm-client.cc Tue Jun 16 23:24:32 2020 +0200 8.3 @@ -1,7 +1,7 @@ 8.4 /* 8.5 * CPM client to access CPM servers. 8.6 * 8.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 8.8 + * Copyright (C) 2018, 2020 Paul Boddie <paul@boddie.org.uk> 8.9 * 8.10 * This program is free software; you can redistribute it and/or 8.11 * modify it under the terms of the GNU General Public License as 8.12 @@ -26,6 +26,47 @@ 8.13 #include "cpm-ops.h" 8.14 8.15 int 8.16 +Cpm_device_interface::get_lcd_pixel_frequency(uint32_t *frequency) throw() 8.17 +{ 8.18 + L4::Ipc::Iostream s(l4_utcb()); 8.19 + int err = l4_error(s.call(cap(), Cpm_op_get_lcd_pixel_frequency)); 8.20 + uint32_t _frequency; 8.21 + 8.22 + if (err) 8.23 + return err; 8.24 + 8.25 + s >> _frequency; 8.26 + *frequency = _frequency; 8.27 + return L4_EOK; 8.28 +} 8.29 + 8.30 +int 8.31 +Cpm_device_interface::set_hdmi_frequency(uint32_t frequency) throw() 8.32 +{ 8.33 + L4::Ipc::Iostream s(l4_utcb()); 8.34 + 8.35 + s << frequency; 8.36 + 8.37 + return l4_error(s.call(cap(), Cpm_op_set_hdmi_frequency)); 8.38 +} 8.39 + 8.40 +int 8.41 +Cpm_device_interface::start_hdmi() throw() 8.42 +{ 8.43 + L4::Ipc::Iostream s(l4_utcb()); 8.44 + 8.45 + return l4_error(s.call(cap(), Cpm_op_start_hdmi)); 8.46 +} 8.47 + 8.48 +int 8.49 +Cpm_device_interface::stop_hdmi() throw() 8.50 +{ 8.51 + L4::Ipc::Iostream s(l4_utcb()); 8.52 + 8.53 + return l4_error(s.call(cap(), Cpm_op_stop_hdmi)); 8.54 +} 8.55 + 8.56 +int 8.57 Cpm_device_interface::set_lcd_frequencies(uint32_t pclk, uint8_t multiplier) throw() 8.58 { 8.59 L4::Ipc::Iostream s(l4_utcb());
9.1 --- a/pkg/devices/cpm/src/server/cpm-server.cc Sat Jun 13 21:07:58 2020 +0200 9.2 +++ b/pkg/devices/cpm/src/server/cpm-server.cc Tue Jun 16 23:24:32 2020 +0200 9.3 @@ -1,7 +1,7 @@ 9.4 /* 9.5 * Common CPM server functionality. 9.6 * 9.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 9.8 + * Copyright (C) 2018, 2020 Paul Boddie <paul@boddie.org.uk> 9.9 * 9.10 * This program is free software; you can redistribute it and/or 9.11 * modify it under the terms of the GNU General Public License as 9.12 @@ -43,6 +43,24 @@ 9.13 case L4::Meta::Protocol: 9.14 return L4::Util::handle_meta_request<Cpm_device_interface>(ios); 9.15 9.16 + case Cpm_op_get_lcd_pixel_frequency: 9.17 + ios << _chip->get_lcd_pixel_frequency(); 9.18 + return L4_EOK; 9.19 + 9.20 + case Cpm_op_set_hdmi_frequency: 9.21 + uint32_t frequency; 9.22 + ios >> frequency; 9.23 + _chip->set_hdmi_frequency(frequency); 9.24 + return L4_EOK; 9.25 + 9.26 + case Cpm_op_start_hdmi: 9.27 + _chip->start_hdmi(); 9.28 + return L4_EOK; 9.29 + 9.30 + case Cpm_op_stop_hdmi: 9.31 + _chip->stop_hdmi(); 9.32 + return L4_EOK; 9.33 + 9.34 case Cpm_op_set_lcd_frequencies: 9.35 uint32_t pclk; 9.36 int multiplier;
10.1 --- a/pkg/devices/display/src/Makefile Sat Jun 13 21:07:58 2020 +0200 10.2 +++ b/pkg/devices/display/src/Makefile Tue Jun 16 23:24:32 2020 +0200 10.3 @@ -1,6 +1,6 @@ 10.4 PKGDIR ?= ../.. 10.5 L4DIR ?= $(PKGDIR)/../.. 10.6 10.7 -TARGET := client letux400 qi_lb60 10.8 +TARGET := ci20 client letux400 qi_lb60 10.9 10.10 include $(L4DIR)/mk/subdir.mk
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/pkg/devices/display/src/ci20/Makefile Tue Jun 16 23:24:32 2020 +0200 11.3 @@ -0,0 +1,14 @@ 11.4 +PKGDIR ?= ../../.. 11.5 +L4DIR ?= $(PKGDIR)/../.. 11.6 + 11.7 +TARGET = dev_display_ci20_hdmi 11.8 +MODE = shared 11.9 +PC_FILENAME := devices-display-ci20_hdmi 11.10 + 11.11 +SRC_CC := display-ci20_hdmi.cc 11.12 + 11.13 +PRIVATE_INCDIR += $(PKGDIR)/display/include 11.14 + 11.15 +REQUIRES_LIBS := l4re_c l4re_c-util libdevice-cpm-client libdrivers-hdmi-jz4780 libdrivers-lcd-jz4740 libdrivers-panel-loader libdevice-util 11.16 + 11.17 +include $(L4DIR)/mk/prog.mk
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/pkg/devices/display/src/ci20/display-ci20_hdmi.cc Tue Jun 16 23:24:32 2020 +0200 12.3 @@ -0,0 +1,168 @@ 12.4 +/* 12.5 + * Export MIPS Creator CI20 HDMI display operations as a server. 12.6 + * 12.7 + * Copyright (C) 2018, 2020 Paul Boddie <paul@boddie.org.uk> 12.8 + * 12.9 + * This program is free software; you can redistribute it and/or 12.10 + * modify it under the terms of the GNU General Public License as 12.11 + * published by the Free Software Foundation; either version 2 of 12.12 + * the License, or (at your option) any later version. 12.13 + * 12.14 + * This program is distributed in the hope that it will be useful, 12.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12.17 + * GNU General Public License for more details. 12.18 + * 12.19 + * You should have received a copy of the GNU General Public License 12.20 + * along with this program; if not, write to the Free Software 12.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 12.22 + * Boston, MA 02110-1301, USA 12.23 + */ 12.24 + 12.25 +#include <l4/devices/cpm-client.h> 12.26 +#include <l4/devices/hdmi-jz4780.h> 12.27 +#include <l4/devices/lcd-jz4740-config.h> 12.28 +#include <l4/devices/lcd-jz4740-panel.h> 12.29 +#include <l4/devices/panel-loader.h> 12.30 +#include <l4/devices/memory.h> 12.31 + 12.32 +#include <l4/cxx/ipc_server> 12.33 +#include <l4/re/env> 12.34 +#include <l4/re/util/object_registry> 12.35 +#include <l4/sys/capability> 12.36 +#include <l4/sys/factory> 12.37 +#include <l4/sys/icu.h> 12.38 + 12.39 +#include "display-ops.h" 12.40 + 12.41 +/* Virtual addresses for the HDMI register block plus interrupt capability. */ 12.42 + 12.43 +static l4_addr_t hdmi_virt_base = 0, hdmi_virt_base_end = 0; 12.44 +static l4_uint32_t hdmi_irq_start, hdmi_irq_end; 12.45 +static L4::Cap<L4::Irq> hdmi_irq; 12.46 +static L4::Cap<L4::Icu> icu; 12.47 + 12.48 +/* CPM device abstractions. */ 12.49 + 12.50 +static Hdmi_jz4780_chip *hdmi = 0; 12.51 +static L4::Cap<Cpm_device_interface> cpm_device; 12.52 + 12.53 + 12.54 + 12.55 +static int setup_memory(void) 12.56 +{ 12.57 + if (get_memory("jz4780-hdmi", &hdmi_virt_base, &hdmi_virt_base_end)) 12.58 + return 1; 12.59 + 12.60 + if (get_irq("jz4780-hdmi", &hdmi_irq_start, &hdmi_irq_end)) 12.61 + return 1; 12.62 + 12.63 + /* Obtain a reference to the CPM device. */ 12.64 + 12.65 + cpm_device = L4Re::Env::env()->get_cap<Cpm_device_interface>("cpm"); 12.66 + if (!cpm_device.is_valid()) return 1; 12.67 + 12.68 + /* Start the HDMI peripheral. */ 12.69 + 12.70 + cpm_device->stop_hdmi(); 12.71 + cpm_device->set_hdmi_frequency(27000000); 12.72 + cpm_device->start_hdmi(); 12.73 + 12.74 + /* Load the panel data from the configured library. */ 12.75 + 12.76 + struct Jz4740_lcd_panel *panel = (struct Jz4740_lcd_panel *) load_panel(); 12.77 + if (!panel) return 1; 12.78 + 12.79 + /* Obtain access to the HDMI interrupt using the ICU. */ 12.80 + 12.81 + icu = L4Re::Env::env()->get_cap<L4::Icu>("icu"); 12.82 + 12.83 + hdmi_irq = L4Re::Util::cap_alloc.alloc<L4::Irq>(); 12.84 + L4Re::Env::env()->factory()->create(hdmi_irq); 12.85 + 12.86 + if (!hdmi_irq.is_valid() || !icu.is_valid()) return 1; 12.87 + 12.88 + /* Bind the IRQ object to the interrupt in this thread. */ 12.89 + 12.90 + int err = l4_error(icu->bind(hdmi_irq_start, hdmi_irq)); 12.91 + if (err) return err; 12.92 + 12.93 + hdmi_irq->bind_thread(L4Re::Env::env()->main_thread(), 0); 12.94 + 12.95 + /* Obtain an abstraction for the HDMI peripheral. */ 12.96 + 12.97 + hdmi = new Hdmi_jz4780_chip(hdmi_virt_base, hdmi_virt_base_end, hdmi_irq.cap(), panel); 12.98 + 12.99 + return 0; 12.100 +} 12.101 + 12.102 + 12.103 + 12.104 +/* Display device. */ 12.105 + 12.106 +class Display_device_server : public L4::Server_object_t<L4::Kobject> 12.107 +{ 12.108 +public: 12.109 + /* Dispatch incoming requests. */ 12.110 + 12.111 + int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios) 12.112 + { 12.113 + l4_msgtag_t tag; 12.114 + 12.115 + (void) obj; 12.116 + ios >> tag; 12.117 + 12.118 + switch (tag.label()) 12.119 + { 12.120 + case Display_op_disable: 12.121 + disable(); 12.122 + return L4_EOK; 12.123 + 12.124 + case Display_op_enable: 12.125 + enable(); 12.126 + return L4_EOK; 12.127 + 12.128 + default: 12.129 + return -L4_EBADPROTO; 12.130 + } 12.131 + } 12.132 + 12.133 + /* Switch the display off. */ 12.134 + 12.135 + void disable(void) 12.136 + { 12.137 + } 12.138 + 12.139 + /* Switch the display on. */ 12.140 + 12.141 + void enable(void) 12.142 + { 12.143 + uint32_t frequency; 12.144 + 12.145 + // NOTE: Should test to see if it is connected. 12.146 + 12.147 + if (!cpm_device->get_lcd_pixel_frequency(&frequency)) 12.148 + { 12.149 + hdmi->enable(frequency); 12.150 + } 12.151 + } 12.152 +}; 12.153 + 12.154 +static L4Re::Util::Registry_server<> server; 12.155 + 12.156 + 12.157 + 12.158 +int main(void) 12.159 +{ 12.160 + if (setup_memory()) return 1; 12.161 + 12.162 + /* Initialise and register a new server object. */ 12.163 + 12.164 + Display_device_server server_obj; 12.165 + server.registry()->register_obj(&server_obj, "display"); 12.166 + 12.167 + /* Enter the IPC server loop. */ 12.168 + 12.169 + server.loop(); 12.170 + return 0; 12.171 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/pkg/devices/lcd/include/lcd-ci20.h Tue Jun 16 23:24:32 2020 +0200 13.3 @@ -0,0 +1,43 @@ 13.4 +/* 13.5 + * LCD device support for the MIPS Creator CI20. 13.6 + * 13.7 + * Copyright (C) 2018, 2020 Paul Boddie <paul@boddie.org.uk> 13.8 + * 13.9 + * This program is free software; you can redistribute it and/or 13.10 + * modify it under the terms of the GNU General Public License as 13.11 + * published by the Free Software Foundation; either version 2 of 13.12 + * the License, or (at your option) any later version. 13.13 + * 13.14 + * This program is distributed in the hope that it will be useful, 13.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 13.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13.17 + * GNU General Public License for more details. 13.18 + * 13.19 + * You should have received a copy of the GNU General Public License 13.20 + * along with this program; if not, write to the Free Software 13.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 13.22 + * Boston, MA 02110-1301, USA 13.23 + */ 13.24 + 13.25 +#pragma once 13.26 + 13.27 +#include "lcd-jz4740-device.h" 13.28 + 13.29 +#ifdef __cplusplus 13.30 + 13.31 +class Lcd_ci20 : public Lcd_jz4740_device 13.32 +{ 13.33 +public: 13.34 + /* Inherit constructor. */ 13.35 + 13.36 + Lcd_ci20(Lcd_chip *chip, L4::Cap<Display_device_interface> display) 13.37 + : Lcd_jz4740_device(chip, display) 13.38 + { 13.39 + } 13.40 + 13.41 + /* Common device instance. */ 13.42 + 13.43 + static Lcd_ci20 *device; 13.44 +}; 13.45 + 13.46 +#endif
14.1 --- a/pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc Sat Jun 13 21:07:58 2020 +0200 14.2 +++ b/pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc Tue Jun 16 23:24:32 2020 +0200 14.3 @@ -1,7 +1,7 @@ 14.4 /* 14.5 * Common LCD device support for the JZ4740 and related SoCs. 14.6 * 14.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 14.8 + * Copyright (C) 2018, 2020 Paul Boddie <paul@boddie.org.uk> 14.9 * 14.10 * This program is free software; you can redistribute it and/or 14.11 * modify it under the terms of the GNU General Public License as 14.12 @@ -22,6 +22,7 @@ 14.13 #include <l4/devices/cpm-client.h> 14.14 #include <l4/devices/display-client.h> 14.15 #include <l4/devices/lcd-jz4740.h> 14.16 +#include <l4/devices/lcd-jz4780.h> 14.17 #include <l4/devices/panel-loader.h> 14.18 #include <l4/devices/memory.h> 14.19 #include "lcd-jz4740-device.h" 14.20 @@ -88,16 +89,24 @@ 14.21 { 14.22 Lcd_jz4740_chip *chip = static_cast<Lcd_jz4740_chip *>(_chip); 14.23 14.24 + // Initialise the clocks for the LCD controller. Without this, the controller 14.25 + // cannot be operated. 14.26 + 14.27 + set_timing(); 14.28 + 14.29 + // Configure the controller. 14.30 + 14.31 chip->disable(); 14.32 chip->config((struct Jz4740_lcd_descriptor *) desc_vaddr, 14.33 (struct Jz4740_lcd_descriptor *) desc_paddr, 14.34 fb_paddr); 14.35 14.36 - // Initialise the clocks for the LCD controller. 14.37 + // Activate the display channel. 14.38 14.39 - set_timing(); 14.40 enable_display(); 14.41 14.42 + // Activate the controller output. 14.43 + 14.44 chip->enable(); 14.45 } 14.46 14.47 @@ -141,10 +150,12 @@ 14.48 14.49 // Allocate memory for the framebuffer at 2**6 == 64 byte == 16 word alignment, 14.50 // also for the descriptors. 14.51 + // NOTE: A 64 word burst mode is available on the JZ4780 that would 14.52 + // NOTE: necessitate 64 word alignment for the framebuffer. 14.53 14.54 const l4_size_t alloc_flags = L4Re::Mem_alloc::Continuous | L4Re::Mem_alloc::Pinned; 14.55 14.56 - if (L4Re::Env::env()->mem_alloc()->alloc(fb_size, _fbmem, alloc_flags, 6) || 14.57 + if (L4Re::Env::env()->mem_alloc()->alloc(fb_size, _fbmem, alloc_flags, 8) || 14.58 L4Re::Env::env()->mem_alloc()->alloc(desc_size, descmem, alloc_flags, 6)) 14.59 return 1; 14.60 14.61 @@ -197,6 +208,15 @@ 14.62 14.63 switch (panel->bpp) 14.64 { 14.65 + // NOTE: 24bpp here is actually RGBA or RGB padded. 14.66 + 14.67 + case 24: 14.68 + view_info->pixel_info.bytes_per_pixel = 4; 14.69 + view_info->pixel_info.r.shift = 16; view_info->pixel_info.r.size = 8; 14.70 + view_info->pixel_info.g.shift = 8; view_info->pixel_info.g.size = 8; 14.71 + view_info->pixel_info.b.shift = 0; view_info->pixel_info.b.size = 8; 14.72 + break; 14.73 + 14.74 case 32: 14.75 view_info->pixel_info.r.shift = 16; view_info->pixel_info.r.size = 8; 14.76 view_info->pixel_info.g.shift = 8; view_info->pixel_info.g.size = 8; 14.77 @@ -231,8 +251,15 @@ 14.78 14.79 static int setup_memory() 14.80 { 14.81 + bool is_jz4780 = false; 14.82 + 14.83 if (get_memory("jz4740-lcd", &lcd_virt_base, &lcd_virt_base_end)) 14.84 - return 1; 14.85 + { 14.86 + if (get_memory("jz4780-lcd", &lcd_virt_base, &lcd_virt_base_end)) 14.87 + return 1; 14.88 + else 14.89 + is_jz4780 = true; 14.90 + } 14.91 14.92 // Obtain access to the CPM and display devices. 14.93 14.94 @@ -248,7 +275,10 @@ 14.95 14.96 // Initialise the LCD abstraction. 14.97 14.98 - lcd_chip = new Lcd_jz4740_chip(lcd_virt_base, panel); 14.99 + if (is_jz4780) 14.100 + lcd_chip = new Lcd_jz4780_chip(lcd_virt_base, panel); 14.101 + else 14.102 + lcd_chip = new Lcd_jz4740_chip(lcd_virt_base, panel); 14.103 14.104 return 0; 14.105 }
15.1 --- a/pkg/devices/lib/cpm/include/cpm-jz4780.h Sat Jun 13 21:07:58 2020 +0200 15.2 +++ b/pkg/devices/lib/cpm/include/cpm-jz4780.h Tue Jun 16 23:24:32 2020 +0200 15.3 @@ -121,7 +121,8 @@ 15.4 uint8_t get_hclock0_source(); 15.5 uint8_t get_hclock2_source(); 15.6 uint8_t get_hdmi_source(); 15.7 - uint8_t get_lcd_source(uint8_t controller = 0); 15.8 + uint8_t get_lcd_source(uint8_t controller); 15.9 + uint8_t get_lcd_source() { return get_lcd_source(0); } 15.10 uint8_t get_memory_source(); 15.11 uint8_t get_pclock_source(); 15.12 15.13 @@ -129,7 +130,8 @@ 15.14 uint32_t get_hclock0_source_frequency(); 15.15 uint32_t get_hclock2_source_frequency(); 15.16 uint32_t get_hdmi_source_frequency(); 15.17 - uint32_t get_lcd_source_frequency(uint8_t controller = 0); 15.18 + uint32_t get_lcd_source_frequency(uint8_t controller); 15.19 + uint32_t get_lcd_source_frequency() { return get_lcd_source_frequency(0); } 15.20 uint32_t get_memory_source_frequency(); 15.21 uint32_t get_pclock_source_frequency(); 15.22 15.23 @@ -139,7 +141,8 @@ 15.24 uint32_t get_hclock0_frequency(); 15.25 uint32_t get_hclock2_frequency(); 15.26 uint32_t get_hdmi_frequency(); 15.27 - uint32_t get_lcd_pixel_frequency(uint8_t controller = 0); 15.28 + uint32_t get_lcd_pixel_frequency(uint8_t controller); 15.29 + uint32_t get_lcd_pixel_frequency() { return get_lcd_pixel_frequency(0); } 15.30 uint32_t get_memory_frequency(); 15.31 uint32_t get_pclock_frequency(); 15.32
16.1 --- a/pkg/devices/lib/cpm/include/cpm.h Sat Jun 13 21:07:58 2020 +0200 16.2 +++ b/pkg/devices/lib/cpm/include/cpm.h Tue Jun 16 23:24:32 2020 +0200 16.3 @@ -1,7 +1,7 @@ 16.4 /* 16.5 * Clock and power management (CPM) abstractions. 16.6 * 16.7 - * Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> 16.8 + * Copyright (C) 2017, 2018, 2020 Paul Boddie <paul@boddie.org.uk> 16.9 * 16.10 * This program is free software; you can redistribute it and/or 16.11 * modify it under the terms of the GNU General Public License as 16.12 @@ -33,6 +33,13 @@ 16.13 class Cpm_chip 16.14 { 16.15 public: 16.16 + virtual uint32_t get_lcd_pixel_frequency() = 0; 16.17 + 16.18 + virtual void set_hdmi_frequency(uint32_t) { } 16.19 + 16.20 + virtual void start_hdmi() { } 16.21 + virtual void stop_hdmi() { } 16.22 + 16.23 virtual void set_lcd_frequencies(uint32_t pclk, uint8_t ratio) = 0; 16.24 16.25 virtual void start_lcd() = 0;
17.1 --- a/pkg/devices/lib/panel/src/Makefile Sat Jun 13 21:07:58 2020 +0200 17.2 +++ b/pkg/devices/lib/panel/src/Makefile Tue Jun 16 23:24:32 2020 +0200 17.3 @@ -1,6 +1,6 @@ 17.4 PKGDIR ?= ../../.. 17.5 L4DIR ?= $(PKGDIR)/../.. 17.6 17.7 -TARGET := letux400 loader qi_lb60 17.8 +TARGET := ci20 letux400 loader qi_lb60 17.9 17.10 include $(L4DIR)/mk/subdir.mk
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 18.2 +++ b/pkg/devices/lib/panel/src/ci20/Makefile Tue Jun 16 23:24:32 2020 +0200 18.3 @@ -0,0 +1,13 @@ 18.4 +PKGDIR ?= ../../../.. 18.5 +L4DIR ?= $(PKGDIR)/../.. 18.6 + 18.7 +TARGET = libpanel_ci20.so 18.8 +PC_FILENAME := libdrivers-panel-ci20 18.9 + 18.10 +SRC_C := panel-ci20.c 18.11 + 18.12 +PRIVATE_INCDIR += $(PKGDIR)/lib/panel/include 18.13 + 18.14 +REQUIRES_LIBS := libdrivers-lcd-headers 18.15 + 18.16 +include $(L4DIR)/mk/lib.mk
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 19.2 +++ b/pkg/devices/lib/panel/src/ci20/panel-ci20.c Tue Jun 16 23:24:32 2020 +0200 19.3 @@ -0,0 +1,61 @@ 19.4 +/* 19.5 + * Export a panel structure for the MIPS Creator CI20. 19.6 + * 19.7 + * Copyright (C) 2018, 2020 Paul Boddie <paul@boddie.org.uk> 19.8 + * 19.9 + * This program is free software; you can redistribute it and/or 19.10 + * modify it under the terms of the GNU General Public License as 19.11 + * published by the Free Software Foundation; either version 2 of 19.12 + * the License, or (at your option) any later version. 19.13 + * 19.14 + * This program is distributed in the hope that it will be useful, 19.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 19.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19.17 + * GNU General Public License for more details. 19.18 + * 19.19 + * You should have received a copy of the GNU General Public License 19.20 + * along with this program; if not, write to the Free Software 19.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19.22 + * Boston, MA 02110-1301, USA 19.23 + */ 19.24 + 19.25 +#include <l4/devices/lcd-jz4740-config.h> 19.26 +#include <l4/devices/lcd-jz4740-panel.h> 19.27 + 19.28 +static struct Jz4740_lcd_panel panel = { 19.29 + .config = ( 19.30 + Jz4740_lcd_mode_tft_generic 19.31 + | Jz4740_lcd_bpp_24 19.32 + | Jz4740_lcd_desc_8_word 19.33 + | Jz4740_lcd_underrun_recover 19.34 + | Jz4740_lcd_ps_disabled 19.35 + | Jz4740_lcd_cls_disabled 19.36 + | Jz4740_lcd_spl_disabled 19.37 + | Jz4740_lcd_rev_disabled 19.38 + | Jz4740_lcd_pclock_negative 19.39 + | Jz4740_lcd_hsync_positive 19.40 + | Jz4740_lcd_vsync_positive 19.41 + | Jz4740_lcd_de_positive), 19.42 + 19.43 + // NOTE: To be configured using the HDMI DDC mechanism. 19.44 + 19.45 + .width = 1280, 19.46 + .height = 1024, 19.47 + .bpp = 24, 19.48 + .frame_rate = 60, 19.49 + .hsync = 112, 19.50 + .vsync = 3, 19.51 + .line_start = 248, // back porch (blanking - hsync - offset) 19.52 + .line_end = 48, // front porch (sync offset) 19.53 + .frame_start = 36, // back porch (blanking - vsync - offset) 19.54 + .frame_end = 3, // front porch (sync offset) 19.55 +}; 19.56 + 19.57 +/* Employ an opaque pointer type. */ 19.58 + 19.59 +void *panel_get(void); 19.60 + 19.61 +void *panel_get(void) 19.62 +{ 19.63 + return &panel; 19.64 +}