# HG changeset patch # User Paul Boddie # Date 1592346006 -7200 # Node ID 1773d15bde89aa58e1ca233a0708efa06c4664b9 # Parent 33dfe120daf0ce3e5ce6d9a1ca86191c127dcaab# Parent 21b57dd374bb1afd83ff889b0a940c761094c86b Merged JZ4780 LCD controller and HDMI peripheral support. diff -r 33dfe120daf0 -r 1773d15bde89 conf/landfall-examples/mips-ci20-common.io --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conf/landfall-examples/mips-ci20-common.io Wed Jun 17 00:20:06 2020 +0200 @@ -0,0 +1,25 @@ +-- vim: ft=lua ts=2 et sw=2 + +-- Configuration file for Io. + +local hw = Io.system_bus() + +Io.add_vbus("cpm", Io.Vi.System_bus +{ + CPM = wrap(hw:match("jz4780-cpm")); +}) + +Io.add_vbus("gpio", Io.Vi.System_bus +{ + GPIO = wrap(hw:match("jz4780-gpio")); +}) + +Io.add_vbus("lcd", Io.Vi.System_bus +{ + LCD = wrap(hw:match("jz4780-lcd")); +}) + +Io.add_vbus("hdmi", Io.Vi.System_bus +{ + HDMI = wrap(hw:match("jz4780-hdmi")); +}) diff -r 33dfe120daf0 -r 1773d15bde89 conf/landfall-examples/mips-ci20-fbdrv.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conf/landfall-examples/mips-ci20-fbdrv.cfg Wed Jun 17 00:20:06 2020 +0200 @@ -0,0 +1,70 @@ +-- vim: ft=lua ts=2 et sw=2 + +-- Start the framebuffer driver with supporting devices. +-- The target platform is the MIPS Creator CI20. + +local L4 = require("L4"); + +local l = L4.default_loader; + +-- Define general access to peripherals. + +local io_buses = { + cpm = l:new_channel(); + gpio = l:new_channel(); + hdmi = l:new_channel(); + lcd = l:new_channel(); + }; + +l:start({ + caps = { + cpm = io_buses.cpm:svr(), + gpio = io_buses.gpio:svr(), + hdmi = io_buses.hdmi:svr(), + lcd = io_buses.lcd:svr(), + + icu = L4.Env.icu, + sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0), + }, + }, + "rom/io rom/hw_devices.io rom/mips-ci20-common.io"); + +-- Expose the CPM peripheral. + +local cpm = l:new_channel(); + +l:start({ + caps = { + vbus = io_buses.cpm, + cpm = cpm:svr(), + }, + }, + "rom/dev_cpm_jz4780"); + +-- Expose a display device for the CI20. + +local display = l:new_channel(); -- exposes display device + +l:start({ + caps = { + cpm = cpm, + display = display:svr(), + icu = L4.Env.icu, + vbus = io_buses.hdmi, -- for HDMI resource access + }, + }, + "rom/dev_display_ci20_hdmi"); + +-- Expose a framebuffer device. + +local fbdrv_fb = l:new_channel(); + +l:start({ + caps = { + vbus = io_buses.lcd, + fb = fbdrv_fb:svr(), + cpm = cpm, + display = display, -- needed by LCD driver + }, + }, + "rom/fb-drv"); diff -r 33dfe120daf0 -r 1773d15bde89 conf/landfall-examples/mips-ci20-fbdrv.list --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conf/landfall-examples/mips-ci20-fbdrv.list Wed Jun 17 00:20:06 2020 +0200 @@ -0,0 +1,18 @@ + +modaddr 0x1100000 + +entry mips-ci20-fbdrv-example +bootstrap bootstrap -serial +kernel fiasco -serial_esc +roottask moe rom/mips-ci20-fbdrv.cfg +module mips-ci20-fbdrv.cfg +module mips-ci20-common.io +module plat-mips-ci20/hw_devices.io +module l4re +module io +module ned +module fb-drv +module dev_display_ci20_hdmi +module dev_cpm_jz4780 +module libpanel_ci20.so +module mips-jz4740-panel.txt diff -r 33dfe120daf0 -r 1773d15bde89 conf/landfall-examples/mips-ci20-hdmi-i2c.cfg --- a/conf/landfall-examples/mips-ci20-hdmi-i2c.cfg Sat Jun 06 22:07:55 2020 +0200 +++ b/conf/landfall-examples/mips-ci20-hdmi-i2c.cfg Wed Jun 17 00:20:06 2020 +0200 @@ -6,12 +6,12 @@ local io_buses = { - hdmi = l:new_channel(); + vbus = l:new_channel(); }; l:start({ caps = { - hdmi = io_buses.hdmi:svr(), + vbus = io_buses.vbus:svr(), icu = L4.Env.icu, sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0), }, @@ -23,7 +23,7 @@ l:start({ caps = { icu = L4.Env.icu, - vbus = io_buses.hdmi, + vbus = io_buses.vbus, }, }, "rom/ex_ci20_hdmi_i2c"); diff -r 33dfe120daf0 -r 1773d15bde89 conf/landfall-examples/mips-ci20-hdmi-i2c.io --- a/conf/landfall-examples/mips-ci20-hdmi-i2c.io Sat Jun 06 22:07:55 2020 +0200 +++ b/conf/landfall-examples/mips-ci20-hdmi-i2c.io Wed Jun 17 00:20:06 2020 +0200 @@ -7,7 +7,8 @@ { CPM = wrap(hw:match("jz4780-cpm")); GPIO = wrap(hw:match("jz4780-gpio")); + LCD = wrap(hw:match("jz4780-lcd")); HDMI = wrap(hw:match("jz4780-hdmi")); } -Io.add_vbus("hdmi", bus) +Io.add_vbus("vbus", bus) diff -r 33dfe120daf0 -r 1773d15bde89 conf/landfall-examples/mips-ci20-spectrum.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conf/landfall-examples/mips-ci20-spectrum.cfg Wed Jun 17 00:20:06 2020 +0200 @@ -0,0 +1,97 @@ +-- vim: ft=lua ts=2 et sw=2 + +-- Start Mag to multiplex the framebuffer showing only a single program. +-- This example shows an animation showing off a spectrum of colours. +-- The target platform is the MIPS Creator CI20. + +local L4 = require("L4"); + +local l = L4.default_loader; + +-- Define general access to peripherals. + +local io_buses = { + cpm = l:new_channel(); + gpio = l:new_channel(); + hdmi = l:new_channel(); + lcd = l:new_channel(); + }; + +l:start({ + caps = { + cpm = io_buses.cpm:svr(), + gpio = io_buses.gpio:svr(), + hdmi = io_buses.hdmi:svr(), + lcd = io_buses.lcd:svr(), + + icu = L4.Env.icu, + sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0), + }, + }, + "rom/io rom/hw_devices.io rom/mips-ci20-common.io"); + +-- Expose the CPM peripheral. + +local cpm = l:new_channel(); + +l:start({ + caps = { + vbus = io_buses.cpm, + cpm = cpm:svr(), + }, + }, + "rom/dev_cpm_jz4780"); + +-- Expose a display device for the CI20. + +local display = l:new_channel(); -- exposes display device + +l:start({ + caps = { + cpm = cpm, + display = display:svr(), + icu = L4.Env.icu, + vbus = io_buses.hdmi, -- for HDMI resource access + }, + }, + "rom/dev_display_ci20_hdmi"); + +-- Expose a framebuffer device. + +local fbdrv_fb = l:new_channel(); + +l:start({ + caps = { + vbus = io_buses.lcd, + fb = fbdrv_fb:svr(), + cpm = cpm, + display = display, -- needed by LCD driver + }, + }, + "rom/fb-drv"); + +-- Multiplex the framebuffer. + +local mag_caps = { + mag = l:new_channel(), + svc = l:new_channel(), + }; + +l:start({ + caps = { + vbus = io_buses.gpio, -- needed by input driver + fb = fbdrv_fb, + mag = mag_caps.mag:svr(), + svc = mag_caps.svc:svr(), + }, + }, + "rom/mag"); + +-- Show the spectrum example. + +l:start({ + caps = { + fb = mag_caps.svc:create(L4.Proto.Goos, "g=1280x1014+0+0", "barheight=10"), + }, + }, + "rom/ex_fb_spectrum_cc"); diff -r 33dfe120daf0 -r 1773d15bde89 conf/landfall-examples/mips-ci20-spectrum.list --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conf/landfall-examples/mips-ci20-spectrum.list Wed Jun 17 00:20:06 2020 +0200 @@ -0,0 +1,20 @@ + +modaddr 0x1100000 + +entry mips-ci20-spectrum-example +bootstrap bootstrap -serial +kernel fiasco -serial_esc +roottask moe rom/mips-ci20-spectrum.cfg +module mips-ci20-spectrum.cfg +module mips-ci20-common.io +module plat-mips-ci20/hw_devices.io +module l4re +module io +module ned +module fb-drv +module mag +module dev_display_ci20_hdmi +module dev_cpm_jz4780 +module ex_fb_spectrum_cc +module libpanel_ci20.so +module mips-jz4740-panel.txt diff -r 33dfe120daf0 -r 1773d15bde89 docs/wiki/Getting_Started --- a/docs/wiki/Getting_Started Sat Jun 06 22:07:55 2020 +0200 +++ b/docs/wiki/Getting_Started Wed Jun 17 00:20:06 2020 +0200 @@ -83,6 +83,8 @@ {{{ mkdir mybuild/images cp conf/landfall-examples/mips-qi_lb60-keypad-demo.list conf/modules.list +~/L4/Landfall/tools/listlibs.sh \ + conf/landfall-examples/mips-qi_lb60-keypad-demo.list >> conf/modules.list make O=mybuild uimage E=mips-qi_lb60-keypad-demo-example }}} @@ -93,6 +95,11 @@ `conf/modules.list`, this being the place where the build system obtains the details of the software to include in the payload. +The module lists provide details of essential programs and resources but may +also require libraries if shared libraries are being used. The `listlibs.sh` +invocation produces a manifest of required libraries for a given list of +programs or modules. This manifest augments the module list provided. + Finally, the make invocation combines programs and libraries found in the `mybuild` directory and uses the indicated payload to construct, in this case, an example demonstrating use of the Ben NanoNote's keypad. diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/Control --- a/pkg/devices/Control Sat Jun 06 22:07:55 2020 +0200 +++ b/pkg/devices/Control Wed Jun 17 00:20:06 2020 +0200 @@ -3,6 +3,7 @@ provides: devices-cpm-jz4730 provides: devices-cpm-jz4740 provides: devices-cpm-jz4780 +provides: devices-display-ci20_hdmi provides: devices-display-letux400 provides: devices-display-qi_lb60 provides: devices-fb-jz4740 @@ -34,6 +35,7 @@ provides: libdrivers-common provides: libdrivers-cpm provides: libdrivers-gpio +provides: libdrivers-hdmi-jz4780 provides: libdrivers-i2c provides: libdrivers-keypad-headers provides: libdrivers-keypad-letux400 @@ -41,6 +43,7 @@ provides: libdrivers-keypad-qi_lb60 provides: libdrivers-lcd-headers provides: libdrivers-lcd-jz4740 +provides: libdrivers-panel-ci20 provides: libdrivers-panel-headers provides: libdrivers-panel-letux400 provides: libdrivers-panel-loader diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/Makefile --- a/pkg/devices/Makefile Sat Jun 06 22:07:55 2020 +0200 +++ b/pkg/devices/Makefile Wed Jun 17 00:20:06 2020 +0200 @@ -11,7 +11,7 @@ backlight: pwm spi cpm: lib util -display: backlight lib util +display: backlight cpm lib util fb: lcd lib util input: keypad lib keypad: lib util diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/cpm/include/cpm-client.h --- a/pkg/devices/cpm/include/cpm-client.h Sat Jun 06 22:07:55 2020 +0200 +++ b/pkg/devices/cpm/include/cpm-client.h Wed Jun 17 00:20:06 2020 +0200 @@ -1,7 +1,7 @@ /* * CPM client to access CPM servers. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2020 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -31,9 +31,17 @@ L4_KOBJECT(Cpm_device_interface) public: + int get_lcd_pixel_frequency(uint32_t *frequency) throw(); + + int set_hdmi_frequency(uint32_t frequency) throw(); int set_lcd_frequencies(uint32_t pclk, uint8_t multiplier) throw(); + + int start_hdmi() throw(); + int stop_hdmi() throw(); + int start_lcd() throw(); int stop_lcd() throw(); + int update_output_frequency() throw(); }; diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/cpm/include/cpm-ops.h --- a/pkg/devices/cpm/include/cpm-ops.h Sat Jun 06 22:07:55 2020 +0200 +++ b/pkg/devices/cpm/include/cpm-ops.h Wed Jun 17 00:20:06 2020 +0200 @@ -1,7 +1,7 @@ /* * CPM server operations. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2020 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -26,4 +26,8 @@ Cpm_op_start_lcd, Cpm_op_stop_lcd, Cpm_op_update_output_frequency, + Cpm_op_get_lcd_pixel_frequency, + Cpm_op_set_hdmi_frequency, + Cpm_op_start_hdmi, + Cpm_op_stop_hdmi, }; diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/cpm/src/client/cpm-client.cc --- a/pkg/devices/cpm/src/client/cpm-client.cc Sat Jun 06 22:07:55 2020 +0200 +++ b/pkg/devices/cpm/src/client/cpm-client.cc Wed Jun 17 00:20:06 2020 +0200 @@ -1,7 +1,7 @@ /* * CPM client to access CPM servers. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2020 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -26,6 +26,47 @@ #include "cpm-ops.h" int +Cpm_device_interface::get_lcd_pixel_frequency(uint32_t *frequency) throw() +{ + L4::Ipc::Iostream s(l4_utcb()); + int err = l4_error(s.call(cap(), Cpm_op_get_lcd_pixel_frequency)); + uint32_t _frequency; + + if (err) + return err; + + s >> _frequency; + *frequency = _frequency; + return L4_EOK; +} + +int +Cpm_device_interface::set_hdmi_frequency(uint32_t frequency) throw() +{ + L4::Ipc::Iostream s(l4_utcb()); + + s << frequency; + + return l4_error(s.call(cap(), Cpm_op_set_hdmi_frequency)); +} + +int +Cpm_device_interface::start_hdmi() throw() +{ + L4::Ipc::Iostream s(l4_utcb()); + + return l4_error(s.call(cap(), Cpm_op_start_hdmi)); +} + +int +Cpm_device_interface::stop_hdmi() throw() +{ + L4::Ipc::Iostream s(l4_utcb()); + + return l4_error(s.call(cap(), Cpm_op_stop_hdmi)); +} + +int Cpm_device_interface::set_lcd_frequencies(uint32_t pclk, uint8_t multiplier) throw() { L4::Ipc::Iostream s(l4_utcb()); diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/cpm/src/server/cpm-server.cc --- a/pkg/devices/cpm/src/server/cpm-server.cc Sat Jun 06 22:07:55 2020 +0200 +++ b/pkg/devices/cpm/src/server/cpm-server.cc Wed Jun 17 00:20:06 2020 +0200 @@ -1,7 +1,7 @@ /* * Common CPM server functionality. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2020 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -43,6 +43,24 @@ case L4::Meta::Protocol: return L4::Util::handle_meta_request(ios); + case Cpm_op_get_lcd_pixel_frequency: + ios << _chip->get_lcd_pixel_frequency(); + return L4_EOK; + + case Cpm_op_set_hdmi_frequency: + uint32_t frequency; + ios >> frequency; + _chip->set_hdmi_frequency(frequency); + return L4_EOK; + + case Cpm_op_start_hdmi: + _chip->start_hdmi(); + return L4_EOK; + + case Cpm_op_stop_hdmi: + _chip->stop_hdmi(); + return L4_EOK; + case Cpm_op_set_lcd_frequencies: uint32_t pclk; int multiplier; diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/display/src/Makefile --- a/pkg/devices/display/src/Makefile Sat Jun 06 22:07:55 2020 +0200 +++ b/pkg/devices/display/src/Makefile Wed Jun 17 00:20:06 2020 +0200 @@ -1,6 +1,6 @@ PKGDIR ?= ../.. L4DIR ?= $(PKGDIR)/../.. -TARGET := client letux400 qi_lb60 +TARGET := ci20 client letux400 qi_lb60 include $(L4DIR)/mk/subdir.mk diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/display/src/ci20/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/display/src/ci20/Makefile Wed Jun 17 00:20:06 2020 +0200 @@ -0,0 +1,14 @@ +PKGDIR ?= ../../.. +L4DIR ?= $(PKGDIR)/../.. + +TARGET = dev_display_ci20_hdmi +MODE = shared +PC_FILENAME := devices-display-ci20_hdmi + +SRC_CC := display-ci20_hdmi.cc + +PRIVATE_INCDIR += $(PKGDIR)/display/include + +REQUIRES_LIBS := l4re_c l4re_c-util libdevice-cpm-client libdrivers-hdmi-jz4780 libdrivers-lcd-jz4740 libdrivers-panel-loader libdevice-util + +include $(L4DIR)/mk/prog.mk diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/display/src/ci20/display-ci20_hdmi.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/display/src/ci20/display-ci20_hdmi.cc Wed Jun 17 00:20:06 2020 +0200 @@ -0,0 +1,168 @@ +/* + * Export MIPS Creator CI20 HDMI display operations as a server. + * + * Copyright (C) 2018, 2020 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "display-ops.h" + +/* Virtual addresses for the HDMI register block plus interrupt capability. */ + +static l4_addr_t hdmi_virt_base = 0, hdmi_virt_base_end = 0; +static l4_uint32_t hdmi_irq_start, hdmi_irq_end; +static L4::Cap hdmi_irq; +static L4::Cap icu; + +/* CPM device abstractions. */ + +static Hdmi_jz4780_chip *hdmi = 0; +static L4::Cap cpm_device; + + + +static int setup_memory(void) +{ + if (get_memory("jz4780-hdmi", &hdmi_virt_base, &hdmi_virt_base_end)) + return 1; + + if (get_irq("jz4780-hdmi", &hdmi_irq_start, &hdmi_irq_end)) + return 1; + + /* Obtain a reference to the CPM device. */ + + cpm_device = L4Re::Env::env()->get_cap("cpm"); + if (!cpm_device.is_valid()) return 1; + + /* Start the HDMI peripheral. */ + + cpm_device->stop_hdmi(); + cpm_device->set_hdmi_frequency(27000000); + cpm_device->start_hdmi(); + + /* Load the panel data from the configured library. */ + + struct Jz4740_lcd_panel *panel = (struct Jz4740_lcd_panel *) load_panel(); + if (!panel) return 1; + + /* Obtain access to the HDMI interrupt using the ICU. */ + + icu = L4Re::Env::env()->get_cap("icu"); + + hdmi_irq = L4Re::Util::cap_alloc.alloc(); + L4Re::Env::env()->factory()->create(hdmi_irq); + + if (!hdmi_irq.is_valid() || !icu.is_valid()) return 1; + + /* Bind the IRQ object to the interrupt in this thread. */ + + int err = l4_error(icu->bind(hdmi_irq_start, hdmi_irq)); + if (err) return err; + + hdmi_irq->bind_thread(L4Re::Env::env()->main_thread(), 0); + + /* Obtain an abstraction for the HDMI peripheral. */ + + hdmi = new Hdmi_jz4780_chip(hdmi_virt_base, hdmi_virt_base_end, hdmi_irq.cap(), panel); + + return 0; +} + + + +/* Display device. */ + +class Display_device_server : public L4::Server_object_t +{ +public: + /* Dispatch incoming requests. */ + + int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios) + { + l4_msgtag_t tag; + + (void) obj; + ios >> tag; + + switch (tag.label()) + { + case Display_op_disable: + disable(); + return L4_EOK; + + case Display_op_enable: + enable(); + return L4_EOK; + + default: + return -L4_EBADPROTO; + } + } + + /* Switch the display off. */ + + void disable(void) + { + } + + /* Switch the display on. */ + + void enable(void) + { + uint32_t frequency; + + // NOTE: Should test to see if it is connected. + + if (!cpm_device->get_lcd_pixel_frequency(&frequency)) + { + hdmi->enable(frequency); + } + } +}; + +static L4Re::Util::Registry_server<> server; + + + +int main(void) +{ + if (setup_memory()) return 1; + + /* Initialise and register a new server object. */ + + Display_device_server server_obj; + server.registry()->register_obj(&server_obj, "display"); + + /* Enter the IPC server loop. */ + + server.loop(); + return 0; +} diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/lcd/include/lcd-ci20.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/lcd/include/lcd-ci20.h Wed Jun 17 00:20:06 2020 +0200 @@ -0,0 +1,43 @@ +/* + * LCD device support for the MIPS Creator CI20. + * + * Copyright (C) 2018, 2020 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#pragma once + +#include "lcd-jz4740-device.h" + +#ifdef __cplusplus + +class Lcd_ci20 : public Lcd_jz4740_device +{ +public: + /* Inherit constructor. */ + + Lcd_ci20(Lcd_chip *chip, L4::Cap display) + : Lcd_jz4740_device(chip, display) + { + } + + /* Common device instance. */ + + static Lcd_ci20 *device; +}; + +#endif diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc --- a/pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc Sat Jun 06 22:07:55 2020 +0200 +++ b/pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc Wed Jun 17 00:20:06 2020 +0200 @@ -1,7 +1,7 @@ /* * Common LCD device support for the JZ4740 and related SoCs. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2020 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include "lcd-jz4740-device.h" @@ -88,16 +89,24 @@ { Lcd_jz4740_chip *chip = static_cast(_chip); + // Initialise the clocks for the LCD controller. Without this, the controller + // cannot be operated. + + set_timing(); + + // Configure the controller. + chip->disable(); chip->config((struct Jz4740_lcd_descriptor *) desc_vaddr, (struct Jz4740_lcd_descriptor *) desc_paddr, fb_paddr); - // Initialise the clocks for the LCD controller. + // Activate the display channel. - set_timing(); enable_display(); + // Activate the controller output. + chip->enable(); } @@ -141,10 +150,12 @@ // Allocate memory for the framebuffer at 2**6 == 64 byte == 16 word alignment, // also for the descriptors. + // NOTE: A 64 word burst mode is available on the JZ4780 that would + // NOTE: necessitate 64 word alignment for the framebuffer. const l4_size_t alloc_flags = L4Re::Mem_alloc::Continuous | L4Re::Mem_alloc::Pinned; - if (L4Re::Env::env()->mem_alloc()->alloc(fb_size, _fbmem, alloc_flags, 6) || + if (L4Re::Env::env()->mem_alloc()->alloc(fb_size, _fbmem, alloc_flags, 8) || L4Re::Env::env()->mem_alloc()->alloc(desc_size, descmem, alloc_flags, 6)) return 1; @@ -197,6 +208,15 @@ switch (panel->bpp) { + // NOTE: 24bpp here is actually RGBA or RGB padded. + + case 24: + view_info->pixel_info.bytes_per_pixel = 4; + view_info->pixel_info.r.shift = 16; view_info->pixel_info.r.size = 8; + view_info->pixel_info.g.shift = 8; view_info->pixel_info.g.size = 8; + view_info->pixel_info.b.shift = 0; view_info->pixel_info.b.size = 8; + break; + case 32: view_info->pixel_info.r.shift = 16; view_info->pixel_info.r.size = 8; view_info->pixel_info.g.shift = 8; view_info->pixel_info.g.size = 8; @@ -231,8 +251,15 @@ static int setup_memory() { + bool is_jz4780 = false; + if (get_memory("jz4740-lcd", &lcd_virt_base, &lcd_virt_base_end)) - return 1; + { + if (get_memory("jz4780-lcd", &lcd_virt_base, &lcd_virt_base_end)) + return 1; + else + is_jz4780 = true; + } // Obtain access to the CPM and display devices. @@ -248,7 +275,10 @@ // Initialise the LCD abstraction. - lcd_chip = new Lcd_jz4740_chip(lcd_virt_base, panel); + if (is_jz4780) + lcd_chip = new Lcd_jz4780_chip(lcd_virt_base, panel); + else + lcd_chip = new Lcd_jz4740_chip(lcd_virt_base, panel); return 0; } diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/lib/Makefile --- a/pkg/devices/lib/Makefile Sat Jun 06 22:07:55 2020 +0200 +++ b/pkg/devices/lib/Makefile Wed Jun 17 00:20:06 2020 +0200 @@ -1,12 +1,13 @@ PKGDIR ?= .. L4DIR ?= $(PKGDIR)/../.. -TARGET := common cpm gpio i2c keypad lcd panel pwm +TARGET := common cpm gpio hdmi i2c keypad lcd panel pwm include $(L4DIR)/mk/subdir.mk cpm: common gpio: common +hdmi: panel i2c: common keypad: common lcd: common diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/lib/cpm/include/cpm-jz4780.h --- a/pkg/devices/lib/cpm/include/cpm-jz4780.h Sat Jun 06 22:07:55 2020 +0200 +++ b/pkg/devices/lib/cpm/include/cpm-jz4780.h Wed Jun 17 00:20:06 2020 +0200 @@ -121,7 +121,8 @@ uint8_t get_hclock0_source(); uint8_t get_hclock2_source(); uint8_t get_hdmi_source(); - uint8_t get_lcd_source(uint8_t controller = 0); + uint8_t get_lcd_source(uint8_t controller); + uint8_t get_lcd_source() { return get_lcd_source(0); } uint8_t get_memory_source(); uint8_t get_pclock_source(); @@ -129,7 +130,8 @@ uint32_t get_hclock0_source_frequency(); uint32_t get_hclock2_source_frequency(); uint32_t get_hdmi_source_frequency(); - uint32_t get_lcd_source_frequency(uint8_t controller = 0); + uint32_t get_lcd_source_frequency(uint8_t controller); + uint32_t get_lcd_source_frequency() { return get_lcd_source_frequency(0); } uint32_t get_memory_source_frequency(); uint32_t get_pclock_source_frequency(); @@ -139,7 +141,8 @@ uint32_t get_hclock0_frequency(); uint32_t get_hclock2_frequency(); uint32_t get_hdmi_frequency(); - uint32_t get_lcd_pixel_frequency(uint8_t controller = 0); + uint32_t get_lcd_pixel_frequency(uint8_t controller); + uint32_t get_lcd_pixel_frequency() { return get_lcd_pixel_frequency(0); } uint32_t get_memory_frequency(); uint32_t get_pclock_frequency(); diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/lib/cpm/include/cpm.h --- a/pkg/devices/lib/cpm/include/cpm.h Sat Jun 06 22:07:55 2020 +0200 +++ b/pkg/devices/lib/cpm/include/cpm.h Wed Jun 17 00:20:06 2020 +0200 @@ -1,7 +1,7 @@ /* * Clock and power management (CPM) abstractions. * - * Copyright (C) 2017, 2018 Paul Boddie + * Copyright (C) 2017, 2018, 2020 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -33,6 +33,13 @@ class Cpm_chip { public: + virtual uint32_t get_lcd_pixel_frequency() = 0; + + virtual void set_hdmi_frequency(uint32_t) { } + + virtual void start_hdmi() { } + virtual void stop_hdmi() { } + virtual void set_lcd_frequencies(uint32_t pclk, uint8_t ratio) = 0; virtual void start_lcd() = 0; diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/lib/hdmi/src/Makefile --- a/pkg/devices/lib/hdmi/src/Makefile Sat Jun 06 22:07:55 2020 +0200 +++ b/pkg/devices/lib/hdmi/src/Makefile Wed Jun 17 00:20:06 2020 +0200 @@ -1,8 +1,8 @@ PKGDIR ?= ../../.. L4DIR ?= $(PKGDIR)/../.. -TARGET = libhdmi.o.a -PC_FILENAME := libdrivers-hdmi +TARGET = libhdmi_jz4780.o.a +PC_FILENAME := libdrivers-hdmi-jz4780 SRC_CC := jz4780.cc diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/lib/panel/src/Makefile --- a/pkg/devices/lib/panel/src/Makefile Sat Jun 06 22:07:55 2020 +0200 +++ b/pkg/devices/lib/panel/src/Makefile Wed Jun 17 00:20:06 2020 +0200 @@ -1,6 +1,6 @@ PKGDIR ?= ../../.. L4DIR ?= $(PKGDIR)/../.. -TARGET := letux400 loader qi_lb60 +TARGET := ci20 letux400 loader qi_lb60 include $(L4DIR)/mk/subdir.mk diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/lib/panel/src/ci20/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/lib/panel/src/ci20/Makefile Wed Jun 17 00:20:06 2020 +0200 @@ -0,0 +1,13 @@ +PKGDIR ?= ../../../.. +L4DIR ?= $(PKGDIR)/../.. + +TARGET = libpanel_ci20.so +PC_FILENAME := libdrivers-panel-ci20 + +SRC_C := panel-ci20.c + +PRIVATE_INCDIR += $(PKGDIR)/lib/panel/include + +REQUIRES_LIBS := libdrivers-lcd-headers + +include $(L4DIR)/mk/lib.mk diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/lib/panel/src/ci20/panel-ci20.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/lib/panel/src/ci20/panel-ci20.c Wed Jun 17 00:20:06 2020 +0200 @@ -0,0 +1,61 @@ +/* + * Export a panel structure for the MIPS Creator CI20. + * + * Copyright (C) 2018, 2020 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#include +#include + +static struct Jz4740_lcd_panel panel = { + .config = ( + Jz4740_lcd_mode_tft_generic + | Jz4740_lcd_bpp_24 + | Jz4740_lcd_desc_8_word + | Jz4740_lcd_underrun_recover + | Jz4740_lcd_ps_disabled + | Jz4740_lcd_cls_disabled + | Jz4740_lcd_spl_disabled + | Jz4740_lcd_rev_disabled + | Jz4740_lcd_pclock_negative + | Jz4740_lcd_hsync_positive + | Jz4740_lcd_vsync_positive + | Jz4740_lcd_de_positive), + + // NOTE: To be configured using the HDMI DDC mechanism. + + .width = 1280, + .height = 1024, + .bpp = 24, + .frame_rate = 60, + .hsync = 112, + .vsync = 3, + .line_start = 248, // back porch (blanking - hsync - offset) + .line_end = 48, // front porch (sync offset) + .frame_start = 36, // back porch (blanking - vsync - offset) + .frame_end = 3, // front porch (sync offset) +}; + +/* Employ an opaque pointer type. */ + +void *panel_get(void); + +void *panel_get(void) +{ + return &panel; +} diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/util/include/memory.h --- a/pkg/devices/util/include/memory.h Sat Jun 06 22:07:55 2020 +0200 +++ b/pkg/devices/util/include/memory.h Wed Jun 17 00:20:06 2020 +0200 @@ -1,7 +1,7 @@ /* - * Memory allocation utility functions. + * Memory and resource allocation utility functions. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2019 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -25,10 +25,16 @@ #include #include +EXTERN_C_BEGIN + int get_device(char const *hid, l4io_device_handle_t *dh, l4io_resource_handle_t *rh); +int get_irq(char const *hid, l4_uint32_t *start, l4_uint32_t *end); + int get_resource(l4io_device_handle_t dh, l4io_resource_t *res, enum l4io_resource_types_t type); int get_memory(char const *hid, l4_addr_t *start, l4_addr_t *end); + +EXTERN_C_END diff -r 33dfe120daf0 -r 1773d15bde89 pkg/devices/util/src/memory.cc --- a/pkg/devices/util/src/memory.cc Sat Jun 06 22:07:55 2020 +0200 +++ b/pkg/devices/util/src/memory.cc Wed Jun 17 00:20:06 2020 +0200 @@ -1,7 +1,7 @@ /* - * Memory allocation utility functions. + * Memory and resource allocation utility functions. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2019 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -33,6 +33,29 @@ return l4io_lookup_device(hid, dh, 0, rh); } +int get_irq(char const *hid, l4_uint32_t *start, l4_uint32_t *end) +{ + l4io_device_handle_t dh; + l4io_resource_handle_t rh; + l4io_resource_t res; + int result; + + result = get_device(hid, &dh, &rh); + + if (result < 0) + return result; + + result = get_resource(dh, &res, L4IO_RESOURCE_IRQ); + + if (result) + return result; + + *start = res.start; + *end = res.end; + + return result; +} + int get_resource(l4io_device_handle_t dh, l4io_resource_t *res, enum l4io_resource_types_t type) { diff -r 33dfe120daf0 -r 1773d15bde89 pkg/landfall-examples/ci20_hdmi_i2c/Makefile --- a/pkg/landfall-examples/ci20_hdmi_i2c/Makefile Sat Jun 06 22:07:55 2020 +0200 +++ b/pkg/landfall-examples/ci20_hdmi_i2c/Makefile Wed Jun 17 00:20:06 2020 +0200 @@ -6,6 +6,6 @@ CFLAGS_ci20_hdmi_i2c.c = -include $(PKGDIR)/ci20_hdmi_i2c/P8021407-crop-1280x1024-16c.c -REQUIRES_LIBS = libio l4re_c-util libdevice-util libdrivers-cpm libdrivers-hdmi libdrivers-lcd-jz4740 libdrivers-gpio libedid +REQUIRES_LIBS = libio l4re_c-util libdevice-util libdrivers-cpm libdrivers-hdmi-jz4780 libdrivers-lcd-jz4740 libdrivers-gpio libedid include $(L4DIR)/mk/prog.mk