<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mathematical Pamphlet &#187; Linux</title>
	<atom:link href="http://www.kennknowles.com/blog/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kennknowles.com/blog</link>
	<description>Mathematics, Haskell, and little bit of Linux</description>
	<lastBuildDate>Sat, 12 Jul 2008 20:17:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Debugging Mesa DRI for the Intel i965 on a Lenovo R61</title>
		<link>http://www.kennknowles.com/blog/2008/07/12/debugging-mesa-dri-for-the-intel-i965-on-a-lenovo-r61/</link>
		<comments>http://www.kennknowles.com/blog/2008/07/12/debugging-mesa-dri-for-the-intel-i965-on-a-lenovo-r61/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 20:17:23 +0000</pubDate>
		<dc:creator>Kenn</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[DRI]]></category>
		<category><![CDATA[i915]]></category>
		<category><![CDATA[i965]]></category>
		<category><![CDATA[Lenovo R61]]></category>
		<category><![CDATA[Mesa]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[X.org]]></category>

		<guid isPermaLink="false">http://www.kennknowles.com/blog/2008/07/12/debugging-mesa-dri-for-the-intel-i965-on-a-lenovo-r61/</guid>
		<description><![CDATA[Here I am trying to crank out something for the ICFP Programming Contest and I have a huge host of OpenGL problems with my new laptop.  This stuff should come in handy for all those people out there with a Lenovo R61 running Gentoo Linux with Mesa 6.5&#8230; all two of them.

Anyhow, no math [...]]]></description>
			<content:encoded><![CDATA[<p>Here I am trying to crank out something for the <a href="http://www.icfpcontest.org/">ICFP Programming Contest</a> and I have a huge host of OpenGL problems with my new laptop.  This stuff should come in handy for all those people out there with a Lenovo R61 running Gentoo Linux with Mesa 6.5&#8230; all two of them.</p>

<p>Anyhow, no math or programming in this post, I&#8217;m afraid, just good old-fashioned system debugging.
<span id="more-65"></span></p>

<h2>Background</h2>

<p>If I run any of the provided servers for the ICFP contest without DRI, I get no output.  This is an <a href="https://projects.cecs.pdx.edu/~jgmorris/icfpc08/index.cgi/wiki/ContestFAQ#IgetablackscreenwhenIruntheserver">FAQ</a> but I&#8217;m on Gentoo and the FAQ is no help.  It is also discussed in <a href="https://projects.cecs.pdx.edu/~jgmorris/icfpc08/index.cgi/ticket/59">this bug report</a>.  Since it seems people have more success with accelerated drivers (why?) and software GL is known to work on my system for other programs, I suspect it is a bug specialized to the libraries used in the provided server.  The quickest way to solve this, I figured, was to try an accelerated DRI driver for the Intel i965 in my Lenovo R61.</p>

<h2>Kernel</h2>

<p>First, I check that the kernel knows about the card and has DRM (the kernel end of DRI) set up:</p>

<pre>
$ zcat /proc/config.gz  | grep DRM
...
CONFIG_DRM=y
...
CONFIG_DRM_I915=y
...
</pre>

<p>The i965 uses the same driver as the i915 so this is good.  Next, <code>dmesg</code>:</p>

<pre>
$ dmesg | grep drm
[drm] Initialized drm 1.1.0 20060810
[drm] Initialized i915 1.6.0 20060119 on minor 0
</pre>

<p>Good.  The kernel is happy.</p>

<h2>X.org</h2>

<p>First, enable DRI in <code>/etc/X11/xorg.conf</code></p>

<pre>
Section "Module"
   ...
   Load "dri"
   ...
EndSection
</pre>

<p>I should point out this other part of my <code>xorg.conf</code>:</p>

<pre>
Section "Device"
   ...
   Driver      "intel"
   ...
EndSection
</pre>

<p>Next, I start X and see what it says about DRI and DRM.</p>

<pre>
$ grep 'dri[^v]' /var/log/Xorg.0.log
(II) LoadModule: "dri"
(II) Loading /usr/lib/xorg/modules/extensions//libdri.so
(II) Module dri: vendor="X.Org Foundation"
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: node name is /dev/dri/card0
(II) intel(0): [dri] visual configs initialized
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: node name is /dev/dri/card0
(II) AIGLX: Loaded and initialized /usr/lib/dri/i965_dri.so
</pre>

<p>Now I run the provided server and it gives output!  But the moment the rover&#8217;s viewing radius clips the edge of the world, my computer crashes!  My <code>/var/log/Xorg.0.log.old</code> tells me this happened:</p>

<pre>
Fatal server error:
lockup
</pre>

<p>Well, yes.  I noticed.  After some googling, I read that it is a known bug with old version of the Mesa library.  But Gentoo has newer versions (major number 7) marked unstable because of known bugs in their interface with the Native Posix Thread Library (i.e. <code>USE=-nptl</code> is mandatory).</p>

<h2>Upgrading Mesa</h2>

<p>I put this in <code>/etc/portage/package.keywords</code>:</p>

<pre>
media-libs/mesa ~x86
</pre>

<p>and the following in <code>/etc/portage/package.use</code> to avoid the <code>nptl</code> bug:</p>

<pre>
media-libs/mesa -nptl
x11-base/xorg-server -nptl
</pre>

<p>The latter is necessary because the setting of the flag must agree between <code>xorg-server</code> and <code>mesa</code> even though this dependency is beyond the capabilities of Portage to reason about.  After re-installing, I go through the above checks again.  The kernel checks out, but X does not:</p>

<pre>
$ grep 'dri[^v]' /var/log/Xorg.0.log.old 
(II) LoadModule: "dri"
(II) Loading /usr/lib/xorg/modules/extensions//libdri.so
(II) Module dri: vendor="X.Org Foundation"
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: node name is /dev/dri/card0
(EE) intel(0): [dri] DRIScreenInit failed. Disabling DRI.
</pre>

<pre>
$ grep drm /var/log/Xorg.0.log.old 
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 8, (OK)
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 8, (OK)
drmOpenByBusid: Searching for BusID pci:0000:00:02.0
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 8, (OK)
drmOpenByBusid: drmOpenMinor returns 8
drmOpenByBusid: drmGetBusid reports pci:0000:00:02.0
(II) intel(0): [drm] DRM interface version 1.0
(II) intel(0): [drm] drmSetBusid failed (8, pci:0000:00:02.0), Permission denied
</pre>

<p>I really don&#8217;t know what this means, and neither does anyone else on the internet really.  <a href="http://dri.freedesktop.org/wiki/DriTroubleshooting">The troubleshooting page</a> on the DRI wiki says this <em>may</em> be caused by your kernel being compiled with a different version of GCC than the DRI driver, but not certainly, and not always.  I do fit this description, so I decided to give it a shot.  A bit nerve-wracking, since I don&#8217;t have a rescue disk with me, but it worked.</p>

<p>End of story.  I can watch my mars rover in beautifully accelerated 3D.  Here&#8217;s the final &#8220;good&#8221; output of all the above <code>grep</code>ing</p>

<pre>
$ dmesg | grep drm
[drm] Initialized drm 1.1.0 20060810
[drm] Initialized i915 1.6.0 20060119 on minor 0
</pre>

<pre>
 $ grep 'dri[^v]' /var/log/Xorg.0.log 
(II) LoadModule: "dri"
(II) Loading /usr/lib/xorg/modules/extensions//libdri.so
(II) Module dri: vendor="X.Org Foundation"
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: node name is /dev/dri/card0
(II) intel(0): [dri] visual configs initialized
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: node name is /dev/dri/card0
(II) AIGLX: Loaded and initialized /usr/lib/dri/i965_dri.so
</pre>

<pre>
$ grep drm /var/log/Xorg.0.log 
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 8, (OK)
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 8, (OK)
drmOpenByBusid: Searching for BusID pci:0000:00:02.0
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 8, (OK)
drmOpenByBusid: drmOpenMinor returns 8
drmOpenByBusid: drmGetBusid reports pci:0000:00:02.0
(II) intel(0): [drm] DRM interface version 1.3
(II) intel(0): [drm] created "i915" driver at busid "pci:0000:00:02.0"
(II) intel(0): [drm] added 8192 byte SAREA at 0xf885d000
(II) intel(0): [drm] mapped SAREA 0xf885d000 to 0xb7fb0000
(II) intel(0): [drm] framebuffer handle = 0xe0050000
(II) intel(0): [drm] added 1 reserved context for kernel
(II) intel(0): [drm] Registers = 0xf8100000
(II) intel(0): [drm] ring buffer = 0xe0000000
(II) intel(0): [drm] init sarea width,height = 1280 x 1280 (pitch 1280)
(II) intel(0): [drm] Back Buffer = 0xe2158000
(II) intel(0): [drm] Depth Buffer = 0xe2798000
(II) intel(0): [drm] textures = 0xe2dd8000
(II) intel(0): [drm] Initialized kernel agp heap manager, 33554432
(II) intel(0): [drm] installed DRM signal handler
(II) intel(0): [drm] dma control initialized, using IRQ 20
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 9, (OK)
drmOpenByBusid: Searching for BusID pci:0000:00:02.0
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 9, (OK)
drmOpenByBusid: drmOpenMinor returns 9
drmOpenByBusid: drmGetBusid reports pci:0000:00:02.0
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.kennknowles.com/blog/2008/07/12/debugging-mesa-dri-for-the-intel-i965-on-a-lenovo-r61/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using HaXml to make a PDF slideshow from an Inkscape SVG</title>
		<link>http://www.kennknowles.com/blog/2008/04/20/using-haxml-to-make-a-pdf-slideshow-from-an-inkscape-svg/</link>
		<comments>http://www.kennknowles.com/blog/2008/04/20/using-haxml-to-make-a-pdf-slideshow-from-an-inkscape-svg/#comments</comments>
		<pubDate>Sun, 20 Apr 2008 09:01:21 +0000</pubDate>
		<dc:creator>Kenn</dc:creator>
				<category><![CDATA[Haskell]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[gournal]]></category>
		<category><![CDATA[HaXml]]></category>
		<category><![CDATA[Inkscape]]></category>
		<category><![CDATA[jarnal]]></category>
		<category><![CDATA[note-taking]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[slide]]></category>
		<category><![CDATA[SVG]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[xournal]]></category>

		<guid isPermaLink="false">http://www.kennknowles.com/blog/2008/04/20/using-haxml-to-make-a-pdf-slideshow-from-an-inkscape-svg/</guid>
		<description><![CDATA[I recently got a tablet to input handwritten math for slideshow presentations, but instead of using a note-taking program (Jarnal,
Xournal,
Gournal) I decided that I wanted the full power of image manipulation of a program like Gimp or Inkscape.  Neither of these, though, has the level of support for multi-page documents that you find in [...]]]></description>
			<content:encoded><![CDATA[<p>I recently got a tablet to input handwritten math for slideshow presentations, but instead of using a note-taking program (<a href="http://www.dklevine.com/general/software/tc1000/jarnal.htm">Jarnal</a>,
<a href="http://xournal.sourceforge.net/">Xournal</a>,
<a href="http://www.adebenham.com/gournal/">Gournal</a>) I decided that I wanted the full power of image manipulation of a program like <a href="http://www.gimp.org/">Gimp</a> or <a href="http://www.inkscape.org/">Inkscape</a>.  Neither of these, though, has the level of support for multi-page documents that you find in note-taking software.  But Inkscape uses SVG as its native file format, so I wrote this Haskell script to transform the layers of an Inkscape SVG file into the slides of a PDF presentation.  I use the
<a href="http://www.cs.york.ac.uk/fp/HaXml/">HaXml</a> library to manipulate the SVG, the Inkscape command-line interface to convert each page to PDF, and <a href="http://www.pdfhacks.com/pdftk/">pdftk</a> to glue the whole thing back together.</p>

<p><a href='http://www.kennknowles.com/blog/wp-content/uploads/2008/04/Slide001.svg' title='slide001.svg'><img width='200' src='http://www.kennknowles.com/blog/wp-content/uploads/2008/04/slide001.png' alt='slide001.png' /></a>
<a href='http://www.kennknowles.com/blog/wp-content/uploads/2008/04/Slide002.svg' title='slide002.png'><img width='200' src='http://www.kennknowles.com/blog/wp-content/uploads/2008/04/slide002.png' alt='slide002.png' /></a></p>

<p><a href='http://www.kennknowles.com/blog/wp-content/uploads/2008/04/Slide003.svg' title='slide003.png'><img width='200' src='http://www.kennknowles.com/blog/wp-content/uploads/2008/04/slide003.png' alt='slide003.png' /></a>
<a href='http://www.kennknowles.com/blog/wp-content/uploads/2008/04/Slide004.svg' title='slide004.png'><img width='200' src='http://www.kennknowles.com/blog/wp-content/uploads/2008/04/slide004.png' alt='slide004.png' /></a></p>

<p>As usual, this post is a literate Haskell file, so you can try it out by saving it to <code>Inkscape.lhs</code>, compiling with <code>ghc --make Inkscape</code>, grabbing the <a href="http://www.kennknowles.com/blog/wp-content/uploads/2008/04/demo.svg">source file for the images above</a>, and running <code>./Inkscape &lt; demo.svg</code>.  The output will appear in <code>Slides.pdf</code> (and your directory will be polluted with temp files, so be aware).
<span id="more-53"></span></p>

<p>For the record, multi-page documents have been on the Inkscape feature
request tracker for many versions, so I presume it is a significant
change.  I <em>do</em> grok C and C++, thanks to the legacy-oriented
education system, but take little enough pleasure from them that I
would rather hack around the issue in Haskell.</p>

<pre>
> import Text.XML.HaXml
> import Text.XML.HaXml.Pretty
> import Text.XML.HaXml.Posn
> import Text.PrettyPrint.HughesPJ
> import Text.Printf
> import Data.List
> import System.IO
> import System.Cmd
</pre>

<p>HaXml is based on a combinator library for <code>CFilter</code>s to filter, search, output, etc XML content.  It is a little crufty in some ways &#8212; many datatypes are transpararent, and you have to do a lot of your own set up and tear down.  The expected way to use it seems to be via <code>processXmlWith :: CFilter -&gt; IO ()</code> which is not sufficient for today&#8217;s task.  The Hackage documentation pointed to an old version of the API, so I used the current version of the source code for documentation.  I&#8217;d love any criticism like &#8220;you didn&#8217;t have to do X&#8221; or &#8220;here is an easier, safer way to do Y&#8221;.</p>

<p>I couldn&#8217;t think of a better way to narrate this code, so I&#8217;ll start with <code>main</code> for a high-level read, and then later fill in all the helper functions. Naturally we start with a call to <code>xmlParse</code>; the <code>"-"</code> is a required filename for error reporting.</p>

<pre>
> main = do input <- getContents
>           let xml = xmlParse "-" input
</pre>

<p>Then I grab the names of all the layer objects in the order they appear in the file, except for the special layer &#8220;Background&#8221; which I&#8217;ll include behind every slide.  The call to <code>verbatim</code> spits them out as <code>String</code>s instead of XML <code>Content</code>, and the <code>"-"</code> is yet another required filename for error reporting.</p>

<pre>
>           let names = delete "Background" 
>                       $ map verbatim 
>                       $ filterElem "-" getLayerNames
>                       $ xmlElem 
>                       $ xml
>           putStrLn $ "Making slides from layers:" 
>                        ++ concatMap ("\n\t"++) names ++ "\n"
</pre>

<p>Then for each layer, make a new version of the file with just that layer visible.</p>

<pre>
>           let outXmls = map (flip selectLayer xml) names
>               usedSlides = take (length names) slideNames
>           mapM_ (uncurry writeFile) 
>                 (zip (map (++".svg") slideNames) 
>                      (map (renderStyle xmlStyle . document) outXmls))
</pre>

<p>And some shell scripting done in Haskell.  I didn&#8217;t even try to find a scripting library or anything to e.g. prevent me from building a malformed command.</p>

<pre>
>           mapM_ (\slide -> do 
>                    system $ "inkscape --export-text-to-path --export-pdf='" 
>                             ++ slide ++ ".pdf' '" ++ slide ++ ".svg'")
>                 usedSlides
>           
>           system $ "pdftk " 
>                      ++ concat (intersperse " " (map (++".pdf") usedSlides)) 
>                      ++ " cat output Slides.pdf"
</pre>

<p>So now to the little details:</p>

<h2>Grabbing the layer names</h2>

<p>Here is the first helper I wrote, wrapping HaXml&#8217;s <code>attrval</code> for a common case.  This filter returns every tag whose <code>attr</code> attribute has the string value <code>val</code>.</p>

<pre>
> matchAttrString :: String -> String -> CFilter i
> matchAttrString attr val = attrval (attr, AttValue [Left val])
</pre>

<p>The next helper is one that maps a tag to its attribute value, otherwise discards anything else it sees.  The HaXml function <code>iffind</code> will pass the <code>attr</code> attribute value of a tag to <code>literal</code> which just returns it.  If the attribute isn&#8217;t found, or the XML data isn&#8217;t a tag, then <code>none</code> will discard it.</p>

<pre>
> showAttr :: String -> CFilter i
> showAttr attr = iffind attr literal none
</pre>

<p>The Inkscape layers are contained in <code>&lt;g inkscape:groupmode='layer' ...&gt;</code> tags.  The name of the layer is in the <code>inkscape:label</code> attribute.  I imagine this will change as Inkscape evolves.  The <code>o</code> is the composition operator for <code>CFilter</code>s.</p>

<pre>
> isLayer = matchAttrString "inkscape:groupmode" "layer"
> getLayerNames = showAttr "inkscape:label" `o` isLayer `o` children
</pre>

<h2>Isolating the layers</h2>

<p>Again proceeding from the outside of my program inwards, a layer is isolated with this helper, using <code>iffind</code> to match either the layer name or the layer &#8220;Background&#8221; which I&#8217;m going to leave in all the output files.  The final <code>keep</code> argument to <code>iffind</code> says to keep
parts of the XML that don&#8217;t have the <code>"inkscape:label"</code> attribute.</p>

<pre>
> selectLayer :: String -> Document Posn -> Document Posn
> selectLayer layer doc = onContent "-" (chip (visible `o` onlyLayer)) doc
>     where onlyLayer = iffind "inkscape:label" layerOrBG keep
>           layerOrBG l = if l == layer || l == "Background" then keep else none
</pre>

<p>In writing <code>visible</code> I was surprised that there was a combinator to set <em>all</em> attributes for a tag, but none to set a single attribute.</p>

<pre>
> visible = setAttr "style" "display:inline"
> setAttr key val (CElem (Elem tag attrs cs) i) = [CElem (Elem tag newattrs cs) i]
>     where newattrs = (key, AttValue [Left val]) : filter ((/= key) . fst) attrs
> setAttr key val other = [other] -- Hackish?
</pre>

<p>As I mentioned before, there is no way that I see to directly apply this filter to an XML file using HaXml.  The type <code>CFilter = Content -&gt; [Content]</code> needs wrapping to apply to an XML <code>Element</code> directly. Notice how I have to pass in a <code>file</code> for error reporting; it feels like I&#8217;m doing things I&#8217;m not supposed to.</p>

<pre>
> filterElem :: FilePath -> CFilter Posn -> Element Posn -> [Content Posn]
> filterElem file f e = f (CElem e (posInNewCxt file Nothing))

> xmlElem (Document _ _ e _) = e
</pre>

<p>And now the function to actually apply a filter to an XML document.  This is straight from the body of <code>processXmlWith</code> in the HaXml source, with <code>filterElem</code> pulled out.</p>

<pre>
> onContent :: FilePath -> (CFilter Posn) -> Document Posn -> Document Posn
> onContent file filter (Document p s e m) =
>     case filterElem file filter e of
>              [CElem e' _] -> Document p s e' m
>              []           -> error "produced no output"
>              _            -> error "produced more than one output"
</pre>

<h2>Bits and pieces</h2>

<p>I also used a modified style for the HughesPJ pretty printer</p>

<pre>
> xmlStyle = style { mode = LeftMode }
</pre>

<p>And a big list of slide names with three digits, for this one-off job.  Better would be to use an API for generating fresh temporary files.</p>

<pre>
> slideNumbers = map (printf "%03d") ([1..999] :: [Int])
> slideNames = map ("Slide"++) slideNumbers
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.kennknowles.com/blog/2008/04/20/using-haxml-to-make-a-pdf-slideshow-from-an-inkscape-svg/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Installing Gentoo on a Dell Latitude D410: USB CDROM bug</title>
		<link>http://www.kennknowles.com/blog/2007/03/13/installing-gentoo-on-a-dell-latitude-d410-usb-cdrom-bug/</link>
		<comments>http://www.kennknowles.com/blog/2007/03/13/installing-gentoo-on-a-dell-latitude-d410-usb-cdrom-bug/#comments</comments>
		<pubDate>Tue, 13 Mar 2007 20:17:36 +0000</pubDate>
		<dc:creator>Kenn</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[laptop. Gentoo]]></category>

		<guid isPermaLink="false">http://www.kennknowles.org/blog/2007/03/13/installing-gentoo-on-a-dell-latitude-d410-usb-cdrom-bug/</guid>
		<description><![CDATA[I&#8217;ve got a borrowed laptop from my advisor that I need to install Gentoo on.  But I have no working CD burners in the house, and only oldish Gentoo CDs, which have bugs in that they don&#8217;t properly initialize and wait for the USB DVD drive (the only removable media this laptop has).  [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve got a borrowed laptop from my advisor that I need to install Gentoo on.  But I have no working CD burners in the house, and only oldish Gentoo CDs, which have bugs in that they don&#8217;t properly initialize and wait for the USB DVD drive (the only removable media this laptop has).  This is fixed since mid-2005 but as I said I&#8217;m scrounging for CDS.  Luckily many quick fixes are floating out there:
<span id="more-14"></span></p>

<p><a href="http://forums.gentoo.org/viewtopic-t-320660.html"> This is the fix I used</a> with LiveCD 2005.0</p>

<ol>
<li> insert the liveCD into your external cdrom</li>
<li>type &#8220;<code>gentoo doscsi</code> [enter]&#8221;
<li>shell (when it gives you an error)</li>
<li>type &#8220;<code>udevstart</code> [enter]&#8221; and exit</li>
<li>type &#8220;<code>/dev/ram0</code> [enter]&#8220;</li>
</ol>

<ul>
 <li>See also: <a href="http://bugs.gentoo.org/show_bug.cgi?id=83276">http://bugs.gentoo.org/show_bug.cgi?id=83276</a> and <a href="http://gentoo-wiki.com/TIP_Installing_Gentoo_using_USB-CDROM">http://gentoo-wiki.com/TIP_Installing_Gentoo_using_USB-CDROM</a></li>
   <li>Aha, there is a page just for this laptop: <a href="http://gentoo-wiki.com/HARDWARE_Dell_Latitude_D410">http://gentoo-wiki.com/HARDWARE_Dell_Latitude_D410</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.kennknowles.com/blog/2007/03/13/installing-gentoo-on-a-dell-latitude-d410-usb-cdrom-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LaTeX editing tools</title>
		<link>http://www.kennknowles.com/blog/2007/02/28/latex-editing-tools/</link>
		<comments>http://www.kennknowles.com/blog/2007/02/28/latex-editing-tools/#comments</comments>
		<pubDate>Wed, 28 Feb 2007 20:13:41 +0000</pubDate>
		<dc:creator>Kenn</dc:creator>
				<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[editors]]></category>

		<guid isPermaLink="false">http://www.kennknowles.org/blog/2007/02/28/latex-editing-tools/</guid>
		<description><![CDATA[Editing LaTeX is very nice with WhizzyTeX but I seem to frequently get version/program conflicts where one or more of emacs/whizzytex/advi are unhappy.  So I came across a variety of emacs helpers for writing TeX with a little less pain; I have yet to try them out so this list is as much for [...]]]></description>
			<content:encoded><![CDATA[<p>Editing LaTeX is very nice with <a href="http://pauillac.inria.fr/whizzytex/">WhizzyTeX</a> but I seem to frequently get version/program conflicts where one or more of emacs/whizzytex/advi are unhappy.  So I came across a variety of emacs helpers for writing TeX with a little less pain; I have yet to try them out so this list is as much for me as anyone else:</p>

<ul>
  <li><a href="http://pauillac.inria.fr/whizzytex/">WhizzyTeX</a> &#8211; realtime preview of TeX in a separate window.  This synergizes the idea of GUI word processing (the important part of WYSIWYG is realtime visualization) and markup languages (which beat all GUI&#8217;s hands-down in terms of ease of editing complex documents).</li>
  <li><a href="http://preview-latex.sourceforge.net/">preview-latex</a> &#8211; has an &#8220;edit&#8221; mode where you hack latex, then when you leave edit mode it renders a little preview.  I haven&#8217;t tried it in depth yet.</li>
  <li><a href="http://sunsite.auc.dk/auctex/">AucTex</a> &#8211; A nice LaTeX major mode (or so I hear)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.kennknowles.com/blog/2007/02/28/latex-editing-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lilo: &#8220;L 99 99 99 99 99 99 99 99&#8243;</title>
		<link>http://www.kennknowles.com/blog/2006/06/04/lilo-l-99-99-99-99-99-99-99-99/</link>
		<comments>http://www.kennknowles.com/blog/2006/06/04/lilo-l-99-99-99-99-99-99-99-99/#comments</comments>
		<pubDate>Sun, 04 Jun 2006 20:09:18 +0000</pubDate>
		<dc:creator>Kenn</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Lilo]]></category>

		<guid isPermaLink="false">http://www.kennknowles.org/blog/2006/06/04/lilo-l-99-99-99-99-99-99-99-99/</guid>
		<description><![CDATA[I compiled a 2.6.16.2 kernel a while ago, and finally got around to rebooting into it. My hd config was insane so I feared rebooting &#8211; and apparently rightly so. Anyhow, I got the following unpleasant error from LILO (analogously from grub, by the way):

L 99 99 99 99 99 99 99 99 ...


The docs [...]]]></description>
			<content:encoded><![CDATA[<p>I compiled a 2.6.16.2 kernel a while ago, and finally got around to rebooting into it. My hd config was insane so I feared rebooting &#8211; and apparently rightly so. Anyhow, I got the following unpleasant error from LILO (analogously from grub, by the way):
<pre>
L 99 99 99 99 99 99 99 99 ...
</pre>
<span id="more-11"></span>
The docs say that lilo can&#8217;t access its map file, probably because of drive geometry mismatch.  Noone on the net suggested this, but in <code>/etc/lilo.conf</code>, changing the line <code>lba32</code>
to
<code>linear</code>
did the trick.  It generated a bunch of warnings about how <code>linear</code> is old and sucks, but it may just be that my hard drive and/or motherboard are also old, and suck.</p>

<p>Another issue I then faced was the lack of devfs, and I don&#8217;t have udev set up (I have no idea what this even involves) and my static dev directory was all permissioned wrong and I wasn&#8217;t sure what permissions are &#8216;&#8217;supposed&#8221; to be on PTYs and TTYs, or even the real difference between them.  Once I have time to do more than a naive chmodding, I may or may not have a useful udev entry.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennknowles.com/blog/2006/06/04/lilo-l-99-99-99-99-99-99-99-99/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Linux on an Apple G4 iBook</title>
		<link>http://www.kennknowles.com/blog/2006/03/28/installing-linux-on-an-apple-g4-ibook/</link>
		<comments>http://www.kennknowles.com/blog/2006/03/28/installing-linux-on-an-apple-g4-ibook/#comments</comments>
		<pubDate>Tue, 28 Mar 2006 19:24:56 +0000</pubDate>
		<dc:creator>Kenn</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Apple]]></category>

		<guid isPermaLink="false">http://www.kennknowles.org/blog/2006/03/28/installing-linux-on-an-apple-g4-ibook/</guid>
		<description><![CDATA[Leading up to my wife going to Japan, we hacked linux onto her Apple G4 iBook. It was sweet. First I&#8217;ll show you a bunch of useful stuff to see if your system is like hers, then I&#8217;ll talk about specific devices.

Here are the devices. The last (Sun GEM) one shows up as unknown device [...]]]></description>
			<content:encoded><![CDATA[<p>Leading up to my wife going to Japan, we hacked linux onto her Apple G4 iBook. It was sweet. First I&#8217;ll show you a bunch of useful stuff to see if your system is like hers, then I&#8217;ll talk about specific devices.
<span id="more-7"></span>
Here are the devices. The last (Sun GEM) one shows up as unknown device until the module is loaded &#8211; see details below under &#8220;wired ethernet&#8221;</p>

<pre style="font-size:8pt">
$ lspci
00:0b.0 Host bridge: Apple Computer Inc. UniNorth 2 AGP
00:10.0 VGA compatible controller: ATI Technologies Inc M9+ 5C63 [Radeon Mobility 9200 (AGP)] (rev 01)
0001:10:0b.0 Host bridge: Apple Computer Inc. UniNorth 2 PCI
0001:10:12.0 Network controller: Broadcom Corporation BCM4306 802.11b/g Wireless LAN Controller (rev 03)
0001:10:17.0 Class ff00: Apple Computer Inc. KeyLargo/Intrepid Mac I/O
0001:10:18.0 USB Controller: Apple Computer Inc. KeyLargo/Intrepid USB
0001:10:19.0 USB Controller: Apple Computer Inc. KeyLargo/Intrepid USB
0001:10:1a.0 USB Controller: Apple Computer Inc. KeyLargo/Intrepid USB
0001:10:1b.0 USB Controller: NEC Corporation USB (rev 43)
0001:10:1b.1 USB Controller: NEC Corporation USB (rev 43)
0001:10:1b.2 USB Controller: NEC Corporation USB 2.0 (rev 04)
0002:20:0b.0 Host bridge: Apple Computer Inc. UniNorth 2 Internal PCI
0002:20:0d.0 Class ff00: Apple Computer Inc. UniNorth/Intrepid ATA/100
0002:20:0e.0 FireWire (IEEE 1394): Apple Computer Inc. UniNorth 2 FireWire (rev 81)
0002:20:0f.0 Ethernet controller: Apple Computer Inc. UniNorth 2 GMAC (Sun GEM) (rev 80)
</pre>

<p>Once the system was running, here&#8217;s what <code>lsmod</code> has to say; some stuff is in the kernel permanently, but I think I tried to make a lot of modules just for the purposes of you being able to see what I did <img src='http://www.kennknowles.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<pre style="font-size:8pt">
$ lsmod
Module                  Size  Used by
snd_pcm_oss            65024  0 
snd_mixer_oss          21984  1 snd_pcm_oss
snd_powermac           51612  0 
snd_pcm               104324  2 snd_pcm_oss,snd_powermac
snd_timer              28164  1 snd_pcm
snd                    69748  5 snd_pcm_oss,snd_mixer_oss,snd_powermac,snd_pcm,snd_timer
soundcore              11396  1 snd
snd_page_alloc         11880  1 snd_pcm
i2c_powermac            6080  0 
i2c_dev                10948  0 
radeon                123976  2
drm                    84120  3 radeon
uninorth_agp           11048  1
agpgart                38428  2 drm,uninorth_agp
bcm43xx               117104  0 
ieee80211softmac       30944  1 bcm43xx
ieee80211              36488  2 bcm43xx,ieee80211softmac
ieee80211_crypt         7072  1 ieee80211
sungem                 36772  0 
sungem_phy             10048  1 sungem
therm_adt746x          14028  0 
hfs                    56804  0 
</pre>

<p>And here are some key files on the system; you&#8217;ll have to do some of your own digging, or read a bit below, to have a clue what they all mean.</p>

<ul>
  <li><a href='http://www.kennknowles.org/blog/wp-content/uploads/2007/11/xorg.conf' title='xorg.conf'>xorg.conf</a></li>
  <li><a href='http://www.kennknowles.org/blog/wp-content/uploads/2007/11/yaboot.conf' title='yaboot.conf'>yaboot.conf</a></li>
  <li><a href='http://www.kennknowles.org/blog/wp-content/uploads/2007/11/config.gz' title='config.gz'>/proc/config.gz</a></li>
</ul>

<p><em>Wired Ethernet</em> &#8211; The wired ethernet card return device class <code>ffff</code> on the PCI bus, blatantly violating spec, so you can&#8217;t inspect what it is. Well, I&#8217;ll tell you: it is a Sun Gem card, and uses the <code>sungem.ko</code> module. Once the module is inserted, then <code>lspci</code> can identify it properly, so the module knows about the spec violation or something</p>

<p><em>Wireless Ethernet</em> &#8211; The broadcom Airport Extreme has drivers now, which is a huge victory for open source I&#8217;d say. The project is at <a href="http://bcm43xx.berlios.de/">http://bcm43xx.berlios.de/</a>. It works perfectly, as far as I can tell.</p>

<p><em>Keyboard</em> &#8211; The keyboard uses the ADB bus so you need to go into the mac driver section and be sure to have that included or you&#8217;ll have a hell of a time, like I did, since a lot of sites claim it is a USB keyboard or some such. I didn&#8217;t remap any of the crazy apple keys, but <code>xmodmap</code> can almost certain do a bang-up job of that. SCIM with <code>scim-anthy</code> works beautifully for Japanese input, by the way.</p>

<p><em>Touchpad</em> &#8211; I didn&#8217;t really do anything to get it to work&#8230; I think I enabled some mac touchpad driver, which is pretty obvious. There is a kernel module to map keys to second and third mouse buttons, and you then configure it in /etc/sysctl.conf</p>

<p><em>Sound </em> &#8211; The ALSA driver <code>snd-powermac.ko</code> depends on i2c stuff (I forget which submodule) but that dependency is not known to <code>modprobe</code>. Be sure to insert all your <code>i2c</code> drivers before <code>snd-powermac</code>. When I failed to do this, I got a kernel panic.</p>

<p><em>Video</em> &#8211; The Radeon works perfectly, with acceleration. I used the <code>radeon.ko</code> kernel module and, if I recall correctly, the radeon X.org driver (as opposed to the ati driver)</p>

<p><em>Booting</em> &#8211; Booting is not too bad, and if you haven&#8217;t done much reading, you won&#8217;t know that you want to use a tool called <code>yaboot</code>. Other useful things are that you hold option key combo to get the mac boot selector, or shift-C to boot from CDROM. You may need to get into the Open Firmware, for which you hold option-apple-O-F.</p>

<p><em>Microphone</em> &#8211; As far as I know, the <code>snd-powermac</code> driver doesn&#8217;t support the built-in mic. So I got a Logitch USB mic, and used the <code>snd-usb</code> or something to that effect. The problem is that the mic device won&#8217;t open unless you specify single channel recording, which most apps don&#8217;t do. So what I did was use the great <code>/etc/asound.conf</code> to create a pseudo-device that just drives the mic single channel as a slave:</p>

<pre>
pcm.mic {
  type plug
  slave {
    pcm "hw:1,0"
    channels 1
    rate 44100
  }
}
</pre>

<p>It is possible I did this file wrong, but I think it is correct. BUT most GUI apps (linphone in particular) don&#8217;t seem to see the virtual mic even though any commandline ALSA app can use it. Probably the GUI apps are using some less-than-ideal way to get a listing of the devices which doesn&#8217;t go through the ALSA configuration layer.</p>

<p><em>Power Management</em> &#8211; A lot of people said this &#8220;just works&#8221; including whatever &#8220;suspend&#8221; it uses, but I didn&#8217;t have time to test it. My wife says it is fine each night as she closes the lid.</p>

<p><em>Goofy Stuff</em> &#8211; There is a kernel module to turn the breathing light into an HDD activity indicator. I think that is sweet so other mac users will think your computer is hyperventilating. Also, I believe you can control the backlight on the screen and thus make your apple logo flicker or something.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennknowles.com/blog/2006/03/28/installing-linux-on-an-apple-g4-ibook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internationalization with SCIM</title>
		<link>http://www.kennknowles.com/blog/2006/01/25/internationalization-with-scim/</link>
		<comments>http://www.kennknowles.com/blog/2006/01/25/internationalization-with-scim/#comments</comments>
		<pubDate>Thu, 01 Jan 1970 07:59:59 +0000</pubDate>
		<dc:creator>Kenn</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[internationalization]]></category>
		<category><![CDATA[Japanese]]></category>
		<category><![CDATA[SCIM]]></category>
		<category><![CDATA[UTF-8]]></category>

		<guid isPermaLink="false">http://www.kennknowles.org/blog/2006/01/25/internationalization-with-scim/</guid>
		<description><![CDATA[I have SCIM and UTF-8 working smoothly with pretty much every program other than emacs.  Here is a narrative of the process I went through; you can skip to the end to see immediately all of what is needed.


A while ago, I installed Scim pretty painlessly for Gtk and Qt apps with the following [...]]]></description>
			<content:encoded><![CDATA[<p>I have SCIM and UTF-8 working smoothly with pretty much every program other than emacs.  Here is a narrative of the process I went through; you can skip to the end to see immediately all of what is needed.
<span id="more-6"></span></p>

<p>A while ago, I installed Scim pretty painlessly for Gtk and Qt apps with the following commands:
<pre>
scim -d
export GTK<em>IM</em>MODULE=scim
export QT<em>IM</em>MODULE=scim
</pre>
But for some reason, I couldn&#8217;t get the more generic XIM working, which would magically allow everything in X to use SCIM and thus input japanese characters. The magic incantations was supposed to just be:
<pre>export XMODIFIERS='@im=SCIM'</pre>
Note that the uppercase <code>SCIM</code> is intentional. Well, as it turns out, I didn&#8217;t have my other locale variables set right &#8211; I had set <code>LC<em>CTYPE='en</em>US.UTF-8'</code> and <code>LANG</code> too. The thing I didn&#8217;t realize is that <code>LC<em>ALL</code> overrides, rather than behaving as a default, and Gentoo&#8217;s default is <code>LC</em>ALL=en<em>US</code>. So by simply unsetting <code>LC</em>ALL</code>, rxvt-unicode and mlterm and Openoffice and mozilla magically starting working with SCIM and also some things that couldn&#8217;t display UTF-8 before all of a sudden could.</p>

<p>Now, I can see japanese text in vim in the console, I can echo it and redirect to a file, I can name files with japanese chars. But the funny thing is I still don&#8217;t have japanese chars or input in gvim or emacs, where you&#8217;d think it might be easier. Well, I don&#8217;t care about gvim but I certainly intend to get it working in emacs.</p>

<p>Another cool thing I did (and the reason for a lot of this) was to write some UTF-8 xml parsing code with PXP and O&#8217;Caml. It was a wonderful experience.</p>

<p>To summarize, here is the process which I believe will get Gentoo japanized, if not totally internationalized:
<pre></p>

<h1>Hopefully, you have USE="nls cjk"</h1>

<h1>Also, some japanese fonts</h1>

<p>emerge uim scim scim-uim scim-qtimm
gtk-query-immodules-2.0 &gt; /etc/gtk-2.0/gtk.immodules
scim -d
export GTK<em>IM</em>MODULE=scim
export QT<em>IM</em>MODULE=scim
export XMODIFIERS='@im=SCIM'
export LC<em>ALL="en</em>US.UTF-8"</p>

<h1>I run them before X</pre></h1>
]]></content:encoded>
			<wfw:commentRss>http://www.kennknowles.com/blog/2006/01/25/internationalization-with-scim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
