Saturday, November 25, 2017

What I Have Lived For

What I Have Lived For
Bertrand Russell

Three passions, simple but overwhelmingly strong, have governed my life: the longing for love, the search for knowledge, and unbearable pity for the suffering of mankind. These passions, like great winds, have blown me hither and thither, in a wayward course, over a great ocean of anguish, reaching to the very verge of despair.

 I have sought love, first, because it brings ecstasy - ecstasy so great that I would often have sacrificed all the rest of life for a few hours of this joy. I have sought it, next, because it relieves loneliness--that terrible loneliness in which one shivering consciousness looks over the rim of the world into the cold unfathomable lifeless abyss. I have sought it finally, because in the union of love I have seen, in a mystic miniature, the prefiguring vision of the heaven that saints and poets have imagined. This is what I sought, and though it might seem too good for human life, this is what--at last--I have found.

With equal passion I have sought knowledge. I have wished to understand the hearts of men. I have wished to know why the stars shine. And I have tried to apprehend the Pythagorean power by which number holds sway above the flux. A little of this, but not much, I have achieved.

 Love and knowledge, so far as they were possible, led upward toward the heavens. But always pity brought me back to earth. Echoes of cries of pain reverberate in my heart. Children in famine, victims tortured by oppressors, helpless old people a burden to their sons, and the whole world of loneliness, poverty, and pain make a mockery of what human life should be. I long to alleviate this evil, but I cannot, and I too suffer.

 This has been my life. I have found it worth living, and would gladly live it again if the chance were offered me.

From The Prologue to Bertrand Russell's Autobiography

Wednesday, July 3, 2013

Create A Custom EDID File Using The Code Under Linux Kernel Tree

      These days I read a article in arch wiki descring how to make kms use a custom  edid file so that can get a acceptable resolution,so I work on it for several days.
Now I has find out how to make it.
Step 1.

 git clone git://anongit.freedesktop.org/xorg/app/edid-decode 

and compile , then copy  edid-decode executable file to /usr/bin.

Step 2.

cvt 1440 900

get this output :

# 1440x900 59.89 Hz (CVT 1.30MA) hsync: 55.93 kHz; pclk: 106.50 MHz
Modeline "1440x900_60.00"  106.50
1440 1528 1672 1904
900 903 909 934
 -hsync +vsync

Step 3.

get the kernel code and unpack , configure and complie, then

add  "edid/1440x900.bin",   to  drivers/gpu/drm/drm_edid_load.c

cd Documentation/EDID
cp 1024x768.S 1440x900.S
nano  1440x900.S

open another window and

nano  HOWTO.txt

then you will see

"X11:
HTimings:  hdisp hsyncstart hsyncend htotal
VTimings:  vdisp vsyncstart vsyncend vtotal

EDID:
#define XPIX hdisp
#define XBLANK htotal-hdisp
#define XOFFSET hsyncstart-hdisp
#define XPULSE hsyncend-hsyncstart

#define YPIX vdisp
#define YBLANK vtotal-vdisp
#define YOFFSET (63+(vsyncstart-vdisp))
#define YPULSE (63+(vsyncend-vsyncstart))"

It means:

HTimings:  hdisp hsyncstart hsyncend htotal
                      1440      1528          1672          1904
VTimings:  vdisp vsyncstart vsyncend vtotal
                      900        903            909             934

then caculate  XPIX  XBLANK  XOFFSET  XPULSE YPIX  YBLANK  YOFFSET  YPULSE youself and edit 1440x900.S

change    #define ESTABLISHED_TIMINGS_BITS 0x0  to
  #define ESTABLISHED_TIMINGS_BITS 0x00 .

As you see, the  -hsync +vsync  also need to be used.

so change

#define HSYNC_POL 0
#define VSYNC_POL 0

to

#define HSYNC_POL 1
#define VSYNC_POL 0

then 

make 

edid-decode 1440x900.bin

you will see that checksum failed and the output will tell you to change 

#define CRC 0x55

the run make again

Step 4.

 mkdir   /lib/firmware/edid

 cp 1440x900.bin /lib/firmware/edid
 cd  ../../

add  CONFIG_EXTRA_FIRMWARE="edid/1440x900.bin"  to .config ,

recompile kernel and copy to the right place.

Step 5.
add drm_kms_helper.edid_firmware=edid/1440x900.bin to grub commandline.


Here is my 1440x900.S

/* EDID */
#define VERSION 1
#define REVISION 3

/* Display */
#define CLOCK 106500 /* kHz */
#define XPIX 1440
#define YPIX 900
#define XY_RATIO XY_RATIO_16_10
#define XBLANK 464
#define YBLANK 34
#define XOFFSET 88
#define XPULSE 144
#define YOFFSET (63+3)
#define YPULSE (63+6)
#define DPI 96
#define VFREQ 60 /* Hz */
#define TIMING_NAME "Linux XGA"
#define ESTABLISHED_TIMINGS_BITS 0x00
#define HSYNC_POL 1
#define VSYNC_POL 0
#define CRC 0xd

#include "edid.S"









Tuesday, May 14, 2013

ATI card switch between radeon and fglrx driver when boot time using systemd script under linux

It's true that the open source driver has been improved very quickly recently.
But if you can't make sure which is better,I suggest you to use both one.
My card is HD4250 , monitor is LG E1908, system is Gentoo.
Sometimes radeon can't display as 1440x900,but fglrx never failed.
fglrx also has a higher performance.But radeon is safer and  easier to use.
There is my scripts. I learn this from gentoo wiki.
I use two kernel.One is 3.9.0 without drm driver called kernel.
One is 3.10-rc1 with latest radeon driver called kernel-git.

Add  After=x11.service  to kdm.service

Create /etc/X11/radeon.conf and /etc/X11/fglrx.conf .

/etc/systemd/system/x11.service

[Unit]
Description=Xserver
[Service]
Type=oneshot
RemainAfterExit=no
ExecStart=/usr/local/sbin/x11.sh

[Install]
WantedBy=multi-user.target


/usr/local/sbin/x11.sh

#!/bin/sh

if   `dmesg | grep -q kernel-git`; then
        eselect opengl set xorg-x11
        ln -sf /etc/X11/radeon.conf /etc/X11/xorg.conf
else
        eselect opengl set ati
        ln -sf /etc/X11/fglrx.conf /etc/X11/xorg.conf
fi

Sunday, February 17, 2013

my make.conf

# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
#CFLAGS="-O2 -pipe"
#CXXFLAGS="${CFLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
#CHOST="x86_64-pc-linux-gnu"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
#USE="mmx sse sse2"
#CC="clang"
#CXX="clang++"
#CXX="clang++ -stdlib=libc++"
CFLAGS="-flto -march=native -O2 -pipe -fomit-frame-pointer -w"
CXXFLAGS="${CFLAGS}"
CHOST="x86_64-pc-linux-gnu"
ACCEPT_KEYWORDS="~amd64"
PKGDIR="/usr/packages"
MAKEOPTS="-j3"
DISTDIR="/usr/distfiles"
PORTAGE_TMPDIR=/tmp
GRUB_PLATFORMS="pc"
ACCEPT_LICENSE="*"
FEATURES="parallel-fetch clean-logs  metadata-transfer  sandbox fail-clean"   #ccache metadata-transfer
#CCACHE_SIZE="15G"
INPUT_DEVICES="evdev keyboard mouse "
VIDEO_CARDS="r600 r700 radeon"
PORTDIR_OVERLAY="/gentoo/linux/ebuild"
LINGUAS="en_US zh_CN "
PYTHON_TARGETS="python2_7    python3_3 "
DRACUT_MODULES="plymouth btrfs systemd"
QEMU_USER_TARGETS="i386  x86_64"
QEMU_SOFTMMU_TARGETS="i386 x86_64"
source /usr/overplay/make.conf
#FETCHCOMMAND="/usr/bin/aria2c -j 8  -t 5   -d  \${DISTDIR}  -o  \${FILE} \${URI}"
#RESUMECOMMAND="${FETCHCOMMAND}"
FETCHCOMMAND="/usr/bin/axel -a -n 8  -o \${DISTDIR}/\${FILE} \${URI}"
RESUMECOMMAND="${FETCHCOMMAND}"
GENTOO_MIRRORS="
http://mirrors.163.com/gentoo
rsync://mirrors.tds.net/gentoo"
SYNC="rsync://rsync26.us.gentoo.org/gentoo-portage"
#SYNC="rsync://mirrors.ustc.edu.cn/gentoo-portage/"
USE_PYTHON="2.7 3.3"
USE="dbus cups alsa -bluetooth consolekit systemd -openrc \
#display
X gles gles2 egl wayland opengl fbcon vaapi vdpau -opencl  \
#cpu
mmx mmx2 sse sse2 ssse3 3dnow 3dnowext mmxext threads  custom-cflags  \
#font
fontconfig xft -cleartype truetype cjk nls unicode lcdfilter \
#destkop
gtk gtk2 gtk3 qt3support kde kde4 qt qt4 icu -gnome -webkit \
#video
vlc gstreamer x264  real direct2d directfb xvmc bluray ffmpeg mpeg  rtmp \
#audio
mp3 midi jack faac timidity lash -pulseaudio \
#image
jpeg mng png imlib jpeg2k gif tiff "