<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>RE: The update of the "Xorg-geode-screensaver" issue and Repair the chaos phenomena transition process about desktop to screensaver</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT COLOR="#000080" SIZE=2 FACE="Arial">Hi, Frank,</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"> <FONT COLOR="#000080" SIZE=2 FACE="Arial">Thank you for your suggestion</FONT><FONT COLOR="#000080" SIZE=2 FACE="Arial">.</FONT> <FONT COLOR="#000080" SIZE=2 FACE="Arial">I know your mean, perhaps the client app</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"> <FONT COLOR="#000080" SIZE=2 FACE="Arial">is right to</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"> <FONT COLOR="#000080" SIZE=2 FACE="Arial">deal with the tables values</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT COLOR="#000080" SIZE=2 FACE="Arial">.</FONT> <FONT COLOR="#000080" SIZE=2 FACE="Arial">N</FONT><FONT COLOR="#000080" SIZE=2 FACE="Arial">ow I use the test-gamma app to reproduce</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT COLOR="#000080" SIZE=2 FACE="Arial"> the</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"> <FONT COLOR="#000080" SIZE=2 FACE="Arial">fading</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"> <FONT COLOR="#000080" SIZE=2 FACE="Arial">phenomenon</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT COLOR="#000080" SIZE=2 FACE="Arial">.</FONT> <FONT COLOR="#000080" SIZE=2 FACE="Arial">I will focus on geode driver part about gamma.</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT COLOR="#000080" SIZE=2 FACE="Arial">Thanks,</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT COLOR="#000080" SIZE=2 FACE="Arial">Hunk Cui</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Tahoma">_____________________________________________<BR>
</FONT></SPAN><SPAN LANG="en-us"><B></B></SPAN><SPAN LANG="en-us"><B><FONT SIZE=2 FACE="Tahoma">From:</FONT></B></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Tahoma"> Huang, FrankR<BR>
</FONT></SPAN><SPAN LANG="en-us"><B></B></SPAN><SPAN LANG="en-us"><B><FONT SIZE=2 FACE="Tahoma">Sent:</FONT></B></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Tahoma"> Monday, May 24, 2010 5:25 PM<BR>
</FONT></SPAN><SPAN LANG="en-us"><B></B></SPAN><SPAN LANG="en-us"><B><FONT SIZE=2 FACE="Tahoma">To:</FONT></B></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Tahoma"></FONT> <FONT SIZE=2 FACE="Tahoma">Cui, Hunk; 'xorg-driver-geode@lists.x.org'<BR>
</FONT></SPAN><SPAN LANG="en-us"><B></B></SPAN><SPAN LANG="en-us"><B><FONT SIZE=2 FACE="Tahoma">Cc:</FONT></B></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Tahoma"> Torres, Rigo; 'Mart Raudsepp'; Ni, John; Xie, Michael; Writer, Tim<BR>
</FONT></SPAN><SPAN LANG="en-us"><B></B></SPAN><SPAN LANG="en-us"><B><FONT SIZE=2 FACE="Tahoma">Subject:</FONT></B></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Tahoma"> RE: The update of the "Xorg-geode-screensaver" issue and Repair the chaos phenomena transition process about desktop to screensaver</FONT></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT COLOR="#000080" SIZE=2 FACE="Arial">Hunk,</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"> <FONT COLOR="#000080" SIZE=2 FACE="Arial">Please check your client application if it has a bug.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"> <FONT COLOR="#000080" SIZE=2 FACE="Arial">If that is not so, modifying the client application is not a good choice. For my opinion, the gamma parameter which is given to Server is not wrong. It</FONT><FONT COLOR="#000080" SIZE=2 FACE="Arial">’</FONT><FONT COLOR="#000080" SIZE=2 FACE="Arial">s a normal value for doing fading…</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"> <FONT COLOR="#000080" SIZE=2 FACE="Arial">I suggest you</FONT><FONT COLOR="#000080" SIZE=2 FACE="Arial"> still need more research on server side code, especially the geode driver part.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT COLOR="#000080" SIZE=2 FACE="Arial">Thanks,</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT COLOR="#000080" SIZE=2 FACE="Arial">Frank</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Tahoma">_____________________________________________<BR>
</FONT></SPAN><SPAN LANG="en-us"><B></B></SPAN><SPAN LANG="en-us"><B><FONT SIZE=2 FACE="Tahoma">From:</FONT></B></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Tahoma"></FONT> <FONT SIZE=2 FACE="Tahoma">Cui, Hunk<BR>
</FONT></SPAN><SPAN LANG="en-us"><B></B></SPAN><SPAN LANG="en-us"><B><FONT SIZE=2 FACE="Tahoma">Sent:</FONT></B></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Tahoma"> 2010</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="宋体">年</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Tahoma">5</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="宋体">月</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Tahoma">24</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="宋体">日</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Tahoma"> 15:47<BR>
</FONT></SPAN><SPAN LANG="en-us"><B></B></SPAN><SPAN LANG="en-us"><B><FONT SIZE=2 FACE="Tahoma">To:</FONT></B></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Tahoma"></FONT> <FONT SIZE=2 FACE="Tahoma">xorg-driver-geode@lists.x.org<BR>
</FONT></SPAN><SPAN LANG="en-us"><B></B></SPAN><SPAN LANG="en-us"><B><FONT SIZE=2 FACE="Tahoma">Cc:</FONT></B></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Tahoma"> Huang, FrankR;</FONT> <FONT SIZE=2 FACE="Tahoma">Torres, Rigo; Mart Raudsepp;</FONT> <FONT SIZE=2 FACE="Tahoma">Ni, John;</FONT> <FONT SIZE=2 FACE="Tahoma">Xie, Michael;</FONT> <FONT SIZE=2 FACE="Tahoma">Writer, Tim<BR>
</FONT></SPAN><SPAN LANG="en-us"><B></B></SPAN><SPAN LANG="en-us"><B><FONT SIZE=2 FACE="Tahoma">Subject:</FONT></B></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Tahoma"> The update of the "Xorg-geode-screensaver" issue and Repair the chaos phenomena transition process about desktop to screensaver</FONT></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">Hi, all,</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">1).</FONT><FONT SIZE=2 FACE="Arial"> The update of the "Xorg-geode-screensaver" issue</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"> <FONT SIZE=2 FACE="Arial">Through communication with TSDB and xorg-devel, I have a certain understanding of this Gamma correction RAM (PAR & PDR registers) principle. All the gamma-related calls, as they are currently implemented,</FONT> <FONT SIZE=2 FACE="Arial">eventually results in writes to the hardware CLUT (Color Lookup Tables) which translates pixel values to actual electrical output values. "Gamma correction" is just one of the things can do by modifying the values in the table. Different hardware has diff</FONT><FONT SIZE=2 FACE="Arial">e</FONT><FONT SIZE=2 FACE="Arial">rent sized CLUTs.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">Some have 8 bits CLUTs (In our Geode-driver, PAD register, 256 bytes space), other may have 10 bits (1024 bytes) and other may have 16 bits. So we store it as a CARD16 and let the driver decide how may bits thy support.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">A client App mak</FONT><FONT SIZE=2 FACE="Arial">e a "gamma correction" call, server generates a new CLUTs with 16 bits of precision per channel, then the driver takes this and truncates to whatever precision the hardware can actually take. Because the gamma ramp is less precise than 16 bits in our geod</FONT><FONT SIZE=2 FACE="Arial">e</FONT><FONT SIZE=2 FACE="Arial">-driver. the R,G,B originality values are 16 bits per channel. When the values are transfered to the driver layer, they will be dealed with through "val = (*red << 8) | *green | (*blue>>8);" because the "val" will be writen into Gamma correction RAM regis</FONT><FONT SIZE=2 FACE="Arial">t</FONT><FONT SIZE=2 FACE="Arial">er (the type of hardware register: Each of the entries are made up of corrections for R/G/B. Within the DWORD, the red correction is in b[23:16], green in b[15:8] and blue in b[7:0]). Finally, our driver is allowed to truncate.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">As a typical use case the C</FONT><FONT SIZE=2 FACE="Arial">LUTs should be able to pass through each value unaltered.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">About different between Graphic data and Video data, in 33234_LX_databook ->P209 Integrated Functions Block Diagram, there are two seperate frame buffers, graphics and video. Assuming both are acti</FONT><FONT SIZE=2 FACE="Arial">ve, these two streams are mixed before being sent to the monitor. Before the mixing, one or the other but not both can be color adjusted using the Gamma Correction RAM.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"> </SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">Now the screensaver belong to the Graphic data, the data will come into the Gamma Cor</FONT><FONT SIZE=2 FACE="Arial">rection RAM, because the luminance generated by a physical device is generally not a linear function of the applied signal, when the Gamma Correction RAM is enabled for graphics use, the data byte of original color is used as an address into the Gamma Cor</FONT><FONT SIZE=2 FACE="Arial">r</FONT><FONT SIZE=2 FACE="Arial">ection RAM which produces a new byte of data, a new color intensity.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">As the screensaver source code (Client App) are more complex, It is hard to trace the major data transfer from Client to Xserver, I have found a simple Client App about Gamma and modifie</FONT><FONT SIZE=2 FACE="Arial">d it (In attachment file). And use DDD-tools, go on to debugging the Gamma client program and Xserver. Finally found the Gamma values be calculated in "gamma_to_ramp" function and produced the 256 bytes data (16-bit). It will be writen to the "Geode drive</FONT><FONT SIZE=2 FACE="Arial">r</FONT><FONT SIZE=2 FACE="Arial"> -> lx_crtc_gamma_set function", The amend method see below:</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Times New Roman"> << File: test-gamma_client-App.rar >></FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"> </SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">static void</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">lx_crtc_gamma_set(xf86CrtcPtr crtc, CARD16 * red, CARD16 * green,</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> CARD16 * blue, int size)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">{</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> unsigned int dcfg;</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> int i;</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"> <FONT SIZE=2 FACE="Arial">DebugP("lx_crtc_gamma_set /by Hunk\n");</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> assert(size == 256);</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> for (i = 0; i < 256; i++) {</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">-- unsigned int val = (*red << 8) | *green | (*blue >> 8);</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">++ unsigned int val = (*(red++) << 8) | *(green++) | (*(blue++) >> 8);</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"> <FONT SIZE=2 FACE="Arial">df_set_video_palette_entry</FONT><FONT SIZE=2 FACE="Arial">(i, val); //Screensaver bug keypoint by Hunk</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> }</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> /* df_set_video_palette_entry automatically turns on</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> * gamma for video - if this gets called, we assume that</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> * RandR wants it set for graphics, so reverse cimarron</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> */</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> dcfg = READ_V</FONT><FONT SIZE=2 FACE="Arial">ID32(DF_DISPLAY_CONFIG);</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> dcfg &= ~DF_DCFG_GV_PAL_BYP;</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> WRITE_VID32(DF_DISPLAY_CONFIG, dcfg);</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">}</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"> </SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"> <FONT SIZE=2 FACE="Arial">Now the update methods have been test in Ubuntu desktop and Fedora desktop. (properly display)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">2).</FONT> <FONT SIZE=2 FACE="Arial">Repair the chaos phenomena transition process about desktop to screensaver</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"> <FONT SIZE=2 FACE="Arial">When the system desktop have been triggered the screensaver, it have a transition process, the display turn chaos and fading to Gamma correction values (1.0 -> 0.01). Debugging th</FONT><FONT SIZE=2 FACE="Arial">e xscreensaver App, I found the client will call “</FONT><FONT SIZE=2 FACE="Arial">xf86GetGammaRamp -> RRCrtcGammaGet ->xf86RandR12CrtcGetGamma”</FONT><FONT SIZE=2 FACE="Arial"> to get the Xserver default Gamma Correction RAM tables, it will be read into client. In client app, the dates of tables will be multiply a coef</FONT><FONT SIZE=2 FACE="Arial">f</FONT><FONT SIZE=2 FACE="Arial">icient (the coefficient is from 1.0 to 0.01). </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">The implement process is “</FONT><FONT SIZE=2 FACE="Arial">main -> main_loop ->blank_screen -> raise_windows -> fade_screens -> xf86_gamma_fade -> xf86_gamma_fade -> tables values multiply a coefficient -> XF86VidModeSetGammaRamp”</FONT><FONT SIZE=2 FACE="Arial">.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">Repair me</FONT><FONT SIZE=2 FACE="Arial">thods: (fade.c -> xf86_gamma_fade function)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> /* Iterate by steps of the animation... */</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> for (i = (out_p ? steps : 0);</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> (out_p ? i > 0 : i < steps);</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> (out_p ? i-- : i++))</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> {</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> for (screen = 0; screen < nscreens; screen++)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"> <FONT SIZE=2 FACE="Arial">{</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">-- xf8</FONT><FONT SIZE=2 FACE="Arial">6_whack_gamma(dpy, screen, &info[screen], (((float)i) / ((float)steps)));</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">++ xf86_whack_gamma(dpy, screen, &info[screen], 1.0); /* changed by Hunk */</FONT></SPAN></P>
<BR>
<P DIR=LTR><SPAN LANG="en-us"> <FONT SIZE=2 FACE="Arial">Now, through the two steps, the phenomena exhibit right from desktop to screensaver.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">3). Welcome ev</FONT><FONT SIZE=2 FACE="Arial">eryone test the code. </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">Find some more other Gamma test App (client program) to reproduce every possible instance based on Graphic data.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN></P>
</BODY>
</HTML>