(was: Create a DRM driver for Matrox G200)

Even after 20 years, the Matrox G200 series is still an excellent 2d graphics card. Unfortunately, there's only an fbdev driver and a user-space driver. Both are obsolete, as modern Linux uses the DRM framework for managing graphics cards. There already is a DRM driver for the G200 server series. This driver is under-maintained and doesn't work with desktop chips.

I intend to work on a DRM driver for the G200 during the hackweek. Let's see how far one can get within a few days. :)

Looking for hackers with the skills:

kernel graphics retro hardware

This project is part of:

Hack Week 17 Hack Week 21

Activity

  • over 3 years ago: ismaell liked this project.
  • over 3 years ago: tdz added keyword "hardware" to this project.
  • over 3 years ago: tdz added keyword "retro" to this project.
  • over 3 years ago: tdz liked this project.
  • over 7 years ago: ptesarik added keyword "kernel" to this project.
  • over 7 years ago: ptesarik added keyword "graphics" to this project.
  • over 7 years ago: ptesarik joined this project.
  • over 7 years ago: ptesarik liked this project.
  • over 7 years ago: tdz started this project.
  • over 7 years ago: mbrugger liked this project.
  • over 7 years ago: mwilck liked this project.
  • over 7 years ago: tdz originated this project.

  • Comments

    • ptesarik
      over 7 years ago by ptesarik | Reply

      G200 is also found in Fujitsu Primergy. Anyway, having a DRM driver sounds like a good step towards a unified graphics stack.

    • tdz
      over 7 years ago by tdz | Reply

      Oh, interresting! I found this: http://www.fujitsu.com/de/products/computing/servers/primergy/os/linux/suse/ and it specifically mentions Primergy. Do we have one of these devices around for testing?

      My plan is to start with desktop cards (because I can do that locally) and at some point merge support for the server. The differences are minor. I mentioned this earlier, the current server-chipset driver is under-maintained and not up to today's DRM. Having desktop support should also help to keep this maintained for the longer term.

    • tdz
      over 7 years ago by tdz | Reply

      From some earlier spare-time work, I already have the power-up code and the DDC code. Next is memory mgmt and modesetting.

    • tdz
      over 7 years ago by tdz | Reply

      Here's what's there so far, not cleaned up:

      https://gitlab.suse.de/tdz/linux/tree/mga-kms

    • tdz
      over 7 years ago by tdz | Reply

      Here's the state after day 1; not cleaned up:

      https://gitlab.suse.de/tdz/linux/tree/mga-kms-day1

      It can do DDC and power-up the device if the BIOS didn't already do so. The fbdev tries to initialize a video mode, but the actual modesetting code is not yet present.

    • tdz
      over 7 years ago by tdz | Reply

      The state of the driver after day 2 is at

      https://gitlab.suse.de/tdz/linux/tree/mga-kms-day2

      I've added code for computing a mode's required memory bandwidth and VCLK (actually Pixel PLL config). This is part of the check-phase of applying a mode. The commit phase is next. Once that works, a lot of clean-up will have to be done.

    • tdz
      over 7 years ago by tdz | Reply

      The state of the driver after day 3 is at

      https://gitlab.suse.de/tdz/linux/tree/mga-kms-day3

      I didn't make much visible progress today, as I was busy with debugging and reading code in the DRM framework.

    • tdz
      over 3 years ago by tdz | Reply

      I think it's time to revive this hackweek project with a slightly different spin.

      Egbert's patches for desktop G200 have landed in the kernel's DRM driver for server G200 a few releases ago. But there's more Matrox desktop hardware that can be supported. I have some half-done patches for G400, etc that I wanted to get finished.

    • tdz
      over 3 years ago by tdz | Reply

      Day 1: The current kernel driver for Matrox supports the various flavors of the G200 chipset. The overall modesetting pipeline is the same for all Matrox cards, but each version's hardware has it's own peculiarities. Therefore, I studied the old userspace driver to understand how it sets up hardware for the G400.

    • tdz
      over 3 years ago by tdz | Reply

      Day 2: I had to do bug fixing in the upstream kernel, so I couldn't commit the morning to the hackweek project. In the afternoon, I went through the old X11 mga driver and tried to transfer the G400's register values and DAC setup code to the kernel driver.

    • tdz
      over 3 years ago by tdz | Reply

      Day 3: I got the G400 working with the mgag200 kernel driver. I took the driver's existing G200 code and adapted it with parameters for the G400. The parameters come from the X11 userspace driver. In the afternoon, I started working on G450 support. The G450 and G550 use a different argorithm for programming the PLL. I'll have to port the existing code from one of the other Matrox drivers into mgag200.

    • tdz
      over 3 years ago by tdz | Reply

      Day 4: I got the Matrox G450 working.

      As I mentioned, the PLL setup algorithm is different from previous cards. The PLL produces an output frequency from a fixes input frequency plus a few circuits that modify it. Such modifications apply divider or multiplier operations to the input frequency in a predefined way. The result is not a 100% match, but usually close enough. Drivers typically take the setting that results in the least difference to the target frequency. (That's why 60 Hz displays usually run with ~59.xx Hz)

      The existing Matrox G450 code is different in that it computes all possible combinations of PLL settings that produce the target frequency and then apply them one by one until the graphics card reports success. Taking this code from the existing fbdev driver requires quite a bit of refactoring to fit it into DRM's atomic modesetting scheme.

    • tdz
      over 3 years ago by tdz | Reply

      Day 5: I worked on cleaning up the G450 code. As I mentioned, the PLL setup algorithm is much more elaborate than for the other models. Integrating this into DRM patterns requires several refactor-debug cycles.

      Overall, I made good progress with the Matrox cards. I have added support for the G400, G400 MAX and the G450. The one left is the G550. Looking at other existing Matrox drivers, it seems very similar to the G450, so it should be relatively easy to support after the G450 code has fallen into place.

      Maybe I'll take the time to finish this and submit the code upstream inclusion.

    Similar Projects

    pudc - A PID 1 process that barks to the internet by mssola

    Description

    As a fun exercise in order to dig deeper into the Linux kernel, its interfaces, the RISC-V architecture, and all the dragons in between; I'm building a blog site cooked like this:

    • The backend is written in a mixture of C and RISC-V assembly.
    • The backend is actually PID1 (for real, not within a container).
    • We poll and parse incoming HTTP requests ourselves.
    • The frontend is a mere HTML page with htmx.

    The project is meant to be Linux-specific, so I'm going to use io_uring, pidfs, namespaces, and Linux-specific features in order to drive all of this.

    I'm open for suggestions and so on, but this is meant to be a solo project, as this is more of a learning exercise for me than anything else.

    Goals

    • Have a better understanding of different Linux features from user space down to the kernel internals.
    • Most importantly: have fun.

    Resources


    bpftrace contribution by mkoutny

    Description

    bpftrace is a great tool, no need to sing odes to it here. It can access any kernel data and process them in real time. It provides helpers for some common Linux kernel structures but not all.

    Goals

    • set up bpftrace toolchain
    • learn about bpftrace implementation and internals
    • implement support for percpu_counters
    • look into some of the first issues
    • send a refined PR (on Thu)

    Resources


    early stage kdump support by mbrugger

    Project Description

    When we experience a early boot crash, we are not able to analyze the kernel dump, as user-space wasn't able to load the crash system. The idea is to make the crash system compiled into the host kernel (think of initramfs) so that we can create a kernel dump really early in the boot process.

    Goal for the Hackweeks

    1. Investigate if this is possible and the implications it would have (done in HW21)
    2. Hack up a PoC (done in HW22 and HW23)
    3. Prepare RFC series (giving it's only one week, we are entering wishful thinking territory here).

    update HW23

    • I was able to include the crash kernel into the kernel Image.
    • I'll need to find a way to load that from init/main.c:start_kernel() probably after kcsan_init()
    • I workaround for a smoke test was to hack kexec_file_load() systemcall which has two problems:
      1. My initramfs in the porduction kernel does not have a new enough kexec version, that's not a blocker but where the week ended
      2. As the crash kernel is part of init.data it will be already stale once I can call kexec_file_load() from user-space.

    The solution is probably to rewrite the POC so that the invocation can be done from init.text (that's my theory) but I'm not sure if I can reuse the kexec infrastructure in the kernel from there, which I rely on heavily.

    update HW24

    • Day1
      • rebased on v6.12 with no problems others then me breaking the config
      • setting up a new compilation and qemu/virtme env
      • getting desperate as nothing works that used to work
    • Day 2
      • getting to call the invocation of loading the early kernel from __init after kcsan_init()
    • Day 3

      • fix problem of memdup not being able to alloc so much memory... use 64K page sizes for now
      • code refactoring
      • I'm now able to load the crash kernel
      • When using virtme I can boot into the crash kernel, also it doesn't boot completely (major milestone!), crash in elfcorehdr_read_notes()
    • Day 4

      • crash systems crashes (no pun intended) in copy_old_mempage() link; will need to understand elfcorehdr...
      • call path vmcore_init() -> parse_crash_elf_headers() -> elfcorehdr_read() -> read_from_oldmem() -> copy_oldmem_page() -> copy_to_iter()
    • Day 5

      • hacking arch/arm64/kernel/crash_dump.c:copy_old_mempage() to see if crash system really starts. It does.
      • fun fact: retested with more reserved memory and with UEFI FW, host kernel crashes in init but directly starts the crash kernel, so it works (somehow) \o/

    update HW25

    • Day 1
      • rebased crash-kernel on v6.12.59 (for now), still crashing


    Add Qualcomm Snapdragon 765G (SM7250) basic device tree to mainline linux kernel by pvorel

    Qualcomm Snapdragon 765G (SM7250) (smartphone SoC) has no support in the linux kernel, nor in u-boot. Try to add basic device tree support. The hardest part will be to create boot.img which will be accepted by phone.

    UART is available for smartphone :).


    Improve UML page fault handler by ptesarik

    Description

    Improve UML handling of segmentation faults in kernel mode. Although such page faults are generally caused by a kernel bug, it is annoying if they cause an infinite loop, or panic the kernel. More importantly, a robust implementation allows to write KUnit tests for various guard pages, preventing potential kernel self-protection regressions.

    Goals

    Convert the UML page fault handler to use oops_* helpers, go through a few review rounds and finally get my patch series merged in 6.14.

    Resources

    Wrong initial attempt: https://lore.kernel.org/lkml/20231215121431.680-1-petrtesarik@huaweicloud.com/T/


    Backfire TV - Take back control of your Firestick by andreabenini

    Take Back Control of Your Amazon Firestick.
    Tired of Ads, a cluttered launcher, and buttons you can't change? BackFireTV is a project to liberate your Firestick from Amazon's walled garden and make it truly yours. They call it the firestick. To fight fire with fire, you need a backfire.
    BackFireTV

    That's the soul of BackFireTV. To truly liberate it and return back to its core capabilities this project uses a linux script, one Android app and ADB access against Amazon's restrictive policies. We leverage these internal tools to create a "backfire" against the incessant ads and locked ecosystem, transforming your Firestick back into the useful, customizable device it was always meant to be.

    The Problem

    The Amazon Firestick starts as an excellent, affordable streaming device. However, Amazon's aggressive Ad policies and restrictive ecosystem have turned it into an increasingly annoying and a less useful device. It comes with frustrations:
    - Messy interface. The less the better was probably the best slogan for the early device, its interface is now cluttered and chaotic when you probably need just a couple of buttons for starting your favorite applications.
    - Constant Ads. The default launcher is filled with commercials and sponsored content.
    - Bloated Interface. A cluttered and slow home screen you can't customize.
    - Locked Buttons. Dedicated buttons for services you don't use (like popular streaming providers) that can't be easily changed.
    - Lack of Control. A closed ecosystem that limits what you can do.

    I could overlook them all if the device was provided for free. But since you pay and you own it it should be legit to do whatever you please in your personal device and network.

    The Solution: BackFireTV

    BackFireTV hacks your Firestick to give you back control. It uses a clever system of DHCP hooks and ADB (Android Debug Bridge) commands to remotely manage your device, block annoyances and customize your experience from the moment it connects to your network.
    The dhcp lease action starts a nohup command on the firestick and forgets about it, the daemon then manages running programs, hacks remote control features and keys. It can be paused or resumed, no rooting required.

    Features

    • Custom Launcher. Automatically replaces the default Amazon launcher with the lean and clean Wolf Launcher.
    • Ad-Free Experience:. Blocks annoying ads and sponsored content for a cleaner interface.
    • Button Remapping. Reprogram the physical buttons on your remote. For example, make the Disney+ button launch Kodi or your favorite application.
    • Works on every firestick 4K. Tested on: Firestick TV 4k (1st/2nd gen), Firestick TV 4k Max.
    • No rooting required. It runs on basic user permissions with standard privileges. It also works on standard devices: latest firmware, with or without external hw attached (usb storage, network cards, usb hubs, ...).
    • No banned apps. This hack relies on the linux subsystem underneath, no matter what Amazon does on the AppStore, this script can always be sideloaded and cannot be banned (no fingerprints on android app layer).
    • Toggle to default anytime. Standard amazon launcher can still be toggled any time for administrative tasks or just as a comparison. Feel free to manage it as usual and switch back to


    Capyboard, ESP32 Development Board for Education by emiler

    Capyboard is an ESP32 development board built to accept individual custom-made modules. The board is created primarily for use in education, where you want to focus on embedded programming instead of spending time with connecting cables and parts on a breadboard, as you would with Arduino and other such devices. The board is not limited only to education and it can be used to build, for instance, a very powerful internal meteo-station and so on.

    Hack Week 25

    My plan is to create a new revision of the board with updated dimensions and possibly even use a new ESP32 with Zigbee/Thread support. I also want to create an extensive library of example projects and expand the documentation. It would be nice to also design additional modules, such as multiplexer or an environment module.

    Goals

    • Implement changes to a new board revision
    • Design additional modules
    • Expand documentation and examples
    • Migrate documentation backend from MkDocs to Zensical

    Hack Week 24

    I created a new motherboard revision after testing my previous prototype, as well as a light module. This project was also a part of my master's thesis, which was defended successfully.

    Goals

    • Finish testing of a new prototype
    • Publish source files
    • Documentation completion
    • Finish writing thesis


    OSHW USB token for Passkeys (FIDO2, U2F, WebAuthn) and PGP by duwe

    Description

    The idea to carry your precious key material along in a specially secured hardware item is almost as old as public keys themselves, starting with the OpenPGP card. Nowadays, an USB plug or NFC are the hardware interfaces of choice, and password-less log-ins are fortunately becoming more popular and standardised.

    Meanwhile there are a few products available in that field, for example

    • yubikey - the "market leader", who continues to sell off buggy, allegedly unfixable firmware ROMs from old stock. Needless to say, it's all but open source, so assume backdoors.

    • nitrokey - the "start" variant is open source, but the hardware was found to leak its flash ROM content via the SWD debugging interface (even when the flash is read protected !)

    • solokey(2) - quite neat hardware, with a secure enclave called "TrustZone-M". Unfortunately, the OSS firmware development is stuck in a rusty dead end and cannot use it.

    I plan to base this project on the not-so-tiny USB stack, which is extremely easy to retarget, and to rewrite / refactor the crypto protocols to use the keys only via handles, so the actual key material can be stored securely. My Initial testbed is the devkit for the solokey2, the NXP LPCXpresso55S69.

    Goals

    Create a proof-of-concept item that can provide a second factor for logins and/or decrypt a PGP mail with your private key without disclosing the key itself. Implement or at least show a migration path to store the private key in a location with elevated hardware security.

    Resources

    LPCXpresso55S69, tropicsquare tropic01, arm-none cross toolchain