mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Johann Klammer <klammerj@a1.net>
To: FlorianSchandinat@gmx.de, linux-kernel@vger.kernel.org,
	linux-fbdev@vger.kernel.org
Subject: [PATCH 07/08] viafb: add mode line converter script
Date: Sat, 5 Dec 2026 23:25:39 +0100	[thread overview]
Message-ID: <7d31a484-e8cc-48ed-9b82-7a7896be0176@a1.net> (raw)

There were other, more subtle
inconsistencies in viafb.modes. wrote a perl
script to generate fb.modes from the table.
also X modelines.

Signed-off-by: Johann Klammer <klammerj@a1.net>
---
diff '--color=auto' -uprN -x '*.o' -x '*.ko' -x '*.mod*' -x '*.a' -x '*.cmd' -x modules.order -x Module.symvers -x .tmp_versions linux-7.3.0-gentoo.orig/drivers/video/fbdev/via/genmodes.pl linux-7.3.0-gentoo.work/drivers/video/fbdev/via/genmodes.pl
--- linux-7.3.0-gentoo.orig/drivers/video/fbdev/via/genmodes.pl	1970-01-01 01:00:00.000000000 +0100
+++ linux-7.3.0-gentoo.work/drivers/video/fbdev/via/genmodes.pl	2026-12-05 20:39:02.136294302 +0100
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use open qw< :encoding(UTF-8) >;
+
+        open(my $in,  "<",  "input.txt")  or die "Can't open input.txt: $!";
+        open(my $mo, ">",  "modelines.txt") or die "Can't open modelines.txt: $!";
+        open(my $fb, ">",  "fbmodes.txt") or die "Can't open fbmodes.txt: $!";
+	$/=undef;
+	my $file = readline($in);
+	$file =~ s{/\*.*?\*/} {}gs;
+	$/="\n";
+	$\="\n";
+	open(my $sf, '<',\$file) or die "Could not open string for reading";
+        while(<$sf>){
+        	if(
+        	my ($name, $refresh, $xres, $yres, $pixclock, $left_margin, $right_margin,
+        	$upper_margin, $lower_margin, $hsync_len, $vsync_len, $sync, $vmode, $flags)=
+        	($_ =~ /\{([^,]+),\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,([^,]+),([^,]+),([^,]+)\}/))
+        	{
+
+        		my $modeline = "# ${xres}x${yres} $refresh Hz\n";
+        		my $dcf = 1/($pixclock * 1.0e-6);
+        		my $hr = $xres;
+        		my $sh1 = $hr + $right_margin;
+        		my $sh2 = $sh1 + $hsync_len;
+        		my $hfl = $sh2 + $left_margin;
+        		my $vr = $yres;
+        		my $sv1 = $vr + $lower_margin;
+        		my $sv2 = $sv1 + $vsync_len;
+        		my $vfl = $sv2 + $upper_margin;
+        		my $mhs = sprintf '%.2f', $dcf;
+        		my $hss = " -HSync";
+        		my $vss = " -VSync";
+        		my $dbs = "";
+        		my $hrf = 1000.0*$dcf/$hfl;
+        		my $hrfs = sprintf '%.2f', $hrf;
+        		if( $sync =~ /FB_SYNC_VERT_HIGH_ACT/){ $vss = " +VSync";}
+        		if( $sync =~ /FB_SYNC_HOR_HIGH_ACT/){ $hss = " +HSync";}
+        		if( $vmode =~ /FB_VMODE_DOUBLE/){ $dbs = " DoubleScan";}
+        		print $mo "${modeline}Modeline \"${xres}x${yres}-${refresh}\" $mhs $hr $sh1 $sh2 $hfl $vr $sv1 $sv2 ${vfl}${dbs}${vss}${hss}";
+        		print $fb "mode \"${xres}x${yres}-${refresh}\"";
+        		print $fb "#D: ${mhs}MHz, H: ${hrfs}kHz, V:${refresh}Hz";
+        		print $fb "geometry $xres $yres $xres $yres 32";
+        		$hss = "";
+        		$vss = "";
+        		$dbs = "";
+        		if( $sync =~ /FB_SYNC_VERT_HIGH_ACT/){ $vss = "vsync high ";}
+        		if( $sync =~ /FB_SYNC_HOR_HIGH_ACT/){ $hss = "hsync high ";}
+        		if( $vmode =~ /FB_VMODE_DOUBLE/){ $dbs = "double true ";}
+        		print $fb "timings $pixclock $left_margin $right_margin $upper_margin $lower_margin $hsync_len $vsync_len ${hss}${vss}${dbs}endmode";
+        	}
+        }
+
+        close $in or die "$in: $!";
+        close $mo or die "$mo: $!";
+        close $fb or die "$fb: $!";
+

                 reply	other threads:[~2026-12-05 22:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7d31a484-e8cc-48ed-9b82-7a7896be0176@a1.net \
    --to=klammerj@a1.net \
    --cc=FlorianSchandinat@gmx.de \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®