paul@83 | 1 | -- vim: ft=lua ts=2 et sw=2 |
paul@83 | 2 | |
paul@83 | 3 | -- Start Mag to multiplex the framebuffer showing only a single program. |
paul@83 | 4 | -- This example shows an animation showing off a spectrum of colours. |
paul@83 | 5 | -- The target platform is the MIPS Creator CI20. |
paul@83 | 6 | |
paul@83 | 7 | local L4 = require("L4"); |
paul@83 | 8 | |
paul@83 | 9 | local l = L4.default_loader; |
paul@83 | 10 | |
paul@83 | 11 | -- Define general access to peripherals. |
paul@83 | 12 | |
paul@83 | 13 | local io_buses = { |
paul@228 | 14 | common = l:new_channel(); |
paul@83 | 15 | }; |
paul@83 | 16 | |
paul@83 | 17 | l:start({ |
paul@83 | 18 | caps = { |
paul@228 | 19 | common = io_buses.common:svr(), |
paul@83 | 20 | icu = L4.Env.icu, |
paul@83 | 21 | sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0), |
paul@83 | 22 | }, |
paul@83 | 23 | }, |
paul@83 | 24 | "rom/io rom/hw_devices.io rom/mips-ci20-common.io"); |
paul@83 | 25 | |
paul@83 | 26 | -- Expose the CPM peripheral. |
paul@83 | 27 | |
paul@83 | 28 | local cpm = l:new_channel(); |
paul@83 | 29 | |
paul@83 | 30 | l:start({ |
paul@83 | 31 | caps = { |
paul@228 | 32 | vbus = io_buses.common, |
paul@83 | 33 | cpm = cpm:svr(), |
paul@83 | 34 | }, |
paul@83 | 35 | }, |
paul@83 | 36 | "rom/dev_cpm_jz4780"); |
paul@83 | 37 | |
paul@83 | 38 | -- Expose a display device for the CI20. |
paul@83 | 39 | |
paul@83 | 40 | local display = l:new_channel(); -- exposes display device |
paul@83 | 41 | |
paul@83 | 42 | l:start({ |
paul@83 | 43 | caps = { |
paul@83 | 44 | cpm = cpm, |
paul@83 | 45 | display = display:svr(), |
paul@83 | 46 | icu = L4.Env.icu, |
paul@228 | 47 | vbus = io_buses.common, -- for HDMI resource access |
paul@83 | 48 | }, |
paul@83 | 49 | }, |
paul@83 | 50 | "rom/dev_display_ci20_hdmi"); |
paul@83 | 51 | |
paul@83 | 52 | -- Expose a framebuffer device. |
paul@83 | 53 | |
paul@83 | 54 | local fbdrv_fb = l:new_channel(); |
paul@83 | 55 | |
paul@83 | 56 | l:start({ |
paul@83 | 57 | caps = { |
paul@228 | 58 | vbus = io_buses.common, |
paul@83 | 59 | fb = fbdrv_fb:svr(), |
paul@83 | 60 | cpm = cpm, |
paul@83 | 61 | display = display, -- needed by LCD driver |
paul@83 | 62 | }, |
paul@83 | 63 | }, |
paul@83 | 64 | "rom/fb-drv"); |
paul@83 | 65 | |
paul@83 | 66 | -- Multiplex the framebuffer. |
paul@83 | 67 | |
paul@83 | 68 | local mag_caps = { |
paul@83 | 69 | mag = l:new_channel(), |
paul@83 | 70 | svc = l:new_channel(), |
paul@83 | 71 | }; |
paul@83 | 72 | |
paul@83 | 73 | l:start({ |
paul@83 | 74 | caps = { |
paul@228 | 75 | vbus = io_buses.common, -- needed by input driver |
paul@83 | 76 | fb = fbdrv_fb, |
paul@83 | 77 | mag = mag_caps.mag:svr(), |
paul@83 | 78 | svc = mag_caps.svc:svr(), |
paul@83 | 79 | }, |
paul@83 | 80 | }, |
paul@83 | 81 | "rom/mag"); |
paul@83 | 82 | |
paul@83 | 83 | -- Show the spectrum example. |
paul@83 | 84 | |
paul@83 | 85 | l:start({ |
paul@83 | 86 | caps = { |
paul@83 | 87 | fb = mag_caps.svc:create(L4.Proto.Goos, "g=1280x1014+0+0", "barheight=10"), |
paul@83 | 88 | }, |
paul@83 | 89 | }, |
paul@83 | 90 | "rom/ex_fb_spectrum_cc"); |