Skip to content

Commit

Permalink
Precised the aim of the kernel patch + some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
TiBeN committed Jan 31, 2016
1 parent 31182ff commit 6ebbca2
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 43 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ Current
<https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel>.
- The linux patchs are now hosted on the repo.
- Fixed and added precision on the KMS setup in the README.md
- $DISPLAY environment var is not hardcoded anymore in gm-15khz but
simply appended to already set $DISPLAY screen number.
17 changes: 10 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ LINUX_HEADERS_ALL_DEB = $(BUILDDIR)/linux-headers-$(KERNEL_BASE_VERSION)-$(KERNE
LINUX_HEADERS_GENERIC_DEB = $(BUILDDIR)/linux-headers-$(KERNEL_BASE_VERSION)-$(KERNEL_ABI_NUMBER)-generic_$(KERNEL_BASE_VERSION)-$(KERNEL_ABI_NUMBER).$(KERNEL_UPLOAD_NUMBER)+patched15khz_amd64.deb
LINUX_IMAGE_DEB = $(BUILDDIR)/linux-image-$(KERNEL_BASE_VERSION)-$(KERNEL_ABI_NUMBER)-generic_$(KERNEL_BASE_VERSION)-$(KERNEL_ABI_NUMBER).$(KERNEL_UPLOAD_NUMBER)+patched15khz_amd64.deb

LINUX_15KHZ_PATCH = src/patch-3.19/linux-3.19.diff
#LINUX_15KHZ_PATCH = src/patch-3.19/linux-3.19.diff
LINUX_15KHZ_PATCH = src/linux-4.2.diff

LINUX_AT9200_PATCH = src/patch-3.19/ati9200_pllfix-3.19.diff
LINUX_AVGA3000_PATCH = src/patch-3.19/avga3000-3.19.diff

Expand Down Expand Up @@ -58,17 +60,16 @@ install:
mkdir -p $(PREFIX)/bin
cp src/bin/gm-15khz $(PREFIX)/bin/
@echo "Install finished"
@echo "Please reboot your computer using the new -patched15khz kernel"
@echo "Please reboot your computer to the new patched kernel"

uninstall:
rm -r $(PREFIX)/lib/15khz-arcade-pkg
rm $(PREFIX)/bin/gm-15khz
apt-get install --reinstall xserver-xorg-video-nouveau
@echo "Uninstall finished."
@echo
@echo "The patched Linux kernel can't be safely uninstalled automatically while running."
@echo "Don't forget to uninstall it manually after booted to another kernel using:"
@echo "sudo apt-get remove linux-image-<version>-patched15khz linux-headers-<version>-patched15khz"
sudo apt-get remove $(notdir $(LINUX_HEADERS_ALL_DEB)) \
$(notdir $(LINUX_HEADERS_GENERIC_DEB)) \
$(notdir $(LINUX_IMAGE_DEB))
@echo "Uninstall finished. Please reboot your computer now"

dist:

Expand Down Expand Up @@ -124,6 +125,8 @@ $(GROOVYMAME_BIN): $(MAME_SRC_PKG) \
cd $(TMPDIR)/mame && patch -p0 --binary < $(realpath $(MAME_HI_PATCH))
cd $(TMPDIR)/mame && patch -p0 --binary < $(realpath $(MAME_GROOVY_PATCH))
cd $(TMPDIR)/mame && MAKEFLAGS= MFLAGS= make
cd $(TMPDIR)/mame && rm mame.zip
cd $(TMPDIR)/mame && make clean
mkdir -p $(BUILDDIR)/groovymame64
cp -r $(TMPDIR)/mame/* $(BUILDDIR)/groovymame64
rm -rf $(TMPDIR)/mame
Expand Down
52 changes: 33 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,39 @@ Arcade videogames monitor running at 15Khz horizontal scan frequencies)
to the VGA output of an Nvidia card using Ubuntu while keeping your
primary screen connected.

One of the aims is to play emulated retro arcade/console/computer games
The goal is to play emulated retro arcade/console/computer games
at real low resolutions on this monitor using emulators like MAME.

Doing this is actually harder than it sounds because:

- Linux kernel disallows 15Khz horizontal scan frequencies which are
used by theses old monitors — 31Khz is now the norm
- For some graphics card, and to enables some features, Linux kernel
must be patched.
- Nvidia Drivers disallow resolutions lower than 320x200
- This setup requires not so obvious Xorg configuration
- Using 15khz monitors require the use of custom
[modelines](https://en.wikipedia.org/wiki/XFree86_Modeline)
unhandled by Xorg nor Mame.
which must be setup manually — There are tools for that.

This project helps to resolve theses issues by providing instructions
and a `Makefile` which help generating:
The content of this file helps to resolve theses issues by providing
instructions for generating:

- A patched Linux kernel wich allows 15Khz modelines as a deb package
- Patched nouveau drivers allowing low resolutions as a deb package
- Patched Mame binary using GroovyMame patch allowing Mame to generate
good 15khz compatible modelines on the fly
good 15khz compatible modelines on the fly.
- A Groovymame bash launcher which sets custom SDL env vars resolving
some weird SDL related behaviors, sets the \$DISPLAY var on the
right screen and tells the linker to use the patched nouveau.dri.so
library.

The generation of theses assets can be done automatically using `make`
or manually by following the provided instructions.
A Makefile is provided for automating the generation and configuration of
most of the following steps.

Motivation
----------

The main purpose of this repository is to keep track and automate steps
needed to achieve this goal. Second motivation is to share hoping that
needed to achieve this goal. Second motivation is to share, hoping that
it might help despite it fits my hardware/OS specifically. If you have
suggestions or knowledges to make it more generic feel free to let me
know.
Expand Down Expand Up @@ -85,7 +85,7 @@ the generation and installation of the assets.

``` {.sourceCode .bash}
$ sudo apt-get build-dep linux-image mame
$ sudo apt-get install fakeroot
$ sudo apt-get install fakeroot qt5-default qtbase5-dev qtbase5-dev-tools
```
2. `git clone` this repository
Expand Down Expand Up @@ -151,11 +151,13 @@ So to launch a program on this screen, prefix the command-line with
$ DISPLAY=:0.1 xrandr
```

### Groovymame

To launch groovymame64:

$ gm-15khz sf2

Note the absence of the prefix DISPLAY=:0.1 . It is useless because it
Note the absence of the env var DISPLAY. It is useless because it
is already set inside the `gm-15khz` bash launcher. `gm-15khz` is simply a
wrapper of the `groovymame64` binary. All command line arguments
following `gm-15khz` invocation are passed to the underlying
Expand All @@ -167,11 +169,23 @@ Detailled instructions for manual setup
This chapter describes step by step how to connects your 15khz monitor
on your computer having an Nvidia card using Ubuntu.

### Allowing the Linux Kernel for 15khz modelines.
### Patching the kernel

As i am not the author of the patchs — thanks to arcadecontrol forum — it
is not very clear to me what is the aim of the patch but i presume
the following:

Linux kernels disallows 15khz modelines to preserve monitors healths.
Patchs for the kernel are made for bypassing this security. Here are the
steps to follow to patch a kernel, compil and boot it.
- The patch allows 15khz modelines in `KMS` mode, which is the display
engine used by the kernel at boot (splashscreen) before Xorg is
launched
- The patch provide diff for ArcadeVGA and ATI cards. I think without
theses thoses cards are not allowed to handle low resolutions or 15khz
modelines.
- **The patch is not required for NVIDIA cards**, at least for mine. Only
patched nouveau drivers — as explained bellow — are required if the
only goal is to play emulators and if you don't care about the
booting phase.
- Patching the Kernel > 3.19, KMS feature doesn't seems to work.

1. Know the version of the installed Kernel:

Expand Down Expand Up @@ -360,7 +374,7 @@ setup, some environment variables must be set:
SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS=1 \
SDL_VIDEO_X11_XRANDR=0 \
SDL_VIDEO_X11_XVIDMODE=0 \
DISPLAY=:0.1 \
DISPLAY=$DISPLAY.1 \
./groovymame sms sonic
```

Expand All @@ -379,8 +393,8 @@ The environment variables are explained below:
action of theses SDL environnment variables is pretty hard
understand but they fix it.

- **DISPLAY=:0.1**: This tells Xorg to execute the program on the
Screen1 (CRT Screen). Note: This number can be :1.1 on your system.
- **DISPLAY=:$DISPLAY.1**: This tells Xorg to execute the program on the
Screen1 (CRT Screen).

The `gm-15khz` bash launcher provided when installing the assets using
the Makefile is basically a wrapper of GroovyMame which sets theses
Expand Down
5 changes: 1 addition & 4 deletions src/bin/gm-15khz
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ export SDL_VIDEO_X11_XVIDMODE=0
export SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS=1

# Tell X to use the second screen
export DISPLAY=:0.1

# Tell MESA to use the patched nouveau_dri.so
export LIBGL_DRIVERS_PATH=$rootPath/../lib/15khz-arcade-pkg
export DISPLAY=$DISPLAY.1

$rootPath/../lib/15khz-arcade-pkg/groovymame64/mame64 $@
13 changes: 0 additions & 13 deletions src/libgl1-mesa-dri-10.5.2-zaphodheads.diff

This file was deleted.

0 comments on commit 6ebbca2

Please sign in to comment.