Several patches for the siliconmotion driver

Paulo Cesar Pereira de Andrade pcpa at
Fri Aug 15 11:35:28 PDT 2008

currojerez at wrote:


  Can you please provide patches for "git-am", i.e. patches
that would be assigned to you, and with a proper description
of what it does. Example:

$ git checkout -b patches
$ <hack>
$ git-commit -a
$ git-checkout master
$ git-format-patch master..patches

  Making one commit for every patch.

  Unless someone objects, I would commit your patches, as well
as try to merge the important bits of some sources I have from
smi, and some code from Alex Deucher, at

  The code/hardware I have is kinda weird, because it is a mips,
and it should not access VGA registers, but it only works
if it access them, and needs a patch on XServer's lnx_video.c
to mmap it when starting the server..., I plan to use Alex's
code to correct it for smi_501, as it is almost functional for
the hardware I have, and changes seems to be trivial to import from
the code from siliconmotion (without needing to hack the X Server
to mmap /dev/mem in the "VGA" range).

> The patch implementing RandR rotation (smi_randr.patch) has some
> problems caused by the screen pixmap header not being correctly
> reconfigured.
> This patch fixes the issue: (I've also uploaded it at
> diff --git a/src/smi_driver.c b/src/smi_driver.c
> index 4136419..729988a 100644
> --- a/src/smi_driver.c
> +++ b/src/smi_driver.c
> @@ -3391,7 +3391,7 @@ static void SMI_SetShadowDimensions(ScrnInfoPtr pScrn,int width,int height){
>      pSmi->Stride = ((pScrn->displayWidth * pSmi->Bpp + 15) & ~15) / pSmi->Bpp;
>      if(pScrn->bitsPerPixel==24)
>         pSmi->Stride*=3;
> -    pScrn->pScreen->ModifyPixmapHeader(pScrn->pScreen->GetScreenPixmap(pScrn->pScreen),-1,-1,-1,-1,width*pSmi->Bpp,NULL);
> +    pScrn->pScreen->ModifyPixmapHeader(pScrn->pScreen->GetScreenPixmap(pScrn->pScreen),width,height,-1,-1,width*pSmi->Bpp,NULL);
>      if(pSmi->EXADriverPtr){
>         pSmi->EXADriverPtr->offScreenBase = pScrn->displayWidth * pSmi->height * pSmi->Bpp;
>      }
> I noticed some artifacts when moving the pointer over a changing
> window on the bottom half of the screen: this is because the damage
> region is clipped to the screen pixmap, and its dimensions weren't
> updated after the rotation.
> On Sat, Aug 09, 2008 at 10:47:35PM +0200, currojerez at wrote:
>> Hi
>> I had some issues with a siliconmotion graphics card (sm720 I think, it's integrated in a laptop computer) so I finally decided to look into the driver code... I think I fixed some bugs (and probably I created some new ones too):
>>  - I couldn't get the shadow framebuffer working to rotate the screen: Xorg crashed with a message saying there were no valid modes. This was because the memory size detection was done after the memory mapping in SMI_PreInit so pSmi->FBReserved wasn't initialized and SMI_ValidMode always returned MODE_MEM.
>>  To fix it I moved the memory detection just before the call to SMI_MapMem
>>  BTW, I couldn't use the VideoRam option in the config file to force the memory size, it seems it's looking for that value in pScrn->videoRam, and it is at pScrn->confScreen->device->videoRam
>>  - Switching between VTs didn't worked ( It left a black screen). I was using the vesafb kernel framebuffer driver. I realised it broke at SMI_PreInit, just after the initialization of the vbe submodule . It fails, anyway, so I placed it inside a conditional depending on pSmi->useBIOS (I also had to use that option to make DPMS work).
>>  - When leaving and then entering into the VT, it was unmapping and remapping the framebuffer, but sometimes the aperture address changed and it crashed when switching back to the X VT because the screen pixmap devPrivate wasn't updated with the new address.
>>  To reproduce, start an X server, switch to a text terminal, start a program in that server and then switch back to X.
>>  I fixed it updating pScrn->pixmapPrivate in SMI_EnterVT, and EXADriverPtr->memoryBase too, in case EXA was being used.
>>  - I implemented RandR rotation. It uses basically the old rotation code, but it seems it is not a good idea to use both simultaneously: if you start an X server with the screen rotated by using the driver option, RandR rotation fails because the RandR extension assumes it isn't initially rotated.
>>  There can be a "Rotate" option  in the Monitor section, it's handled by the randr extension but it seems it needs the newer interface 1.2, otherwise I don't think it would make much sense to keep the driver option.
>>  I had to do some modifications on the code to get this working:
>>   * I added the configuration file option "RandRRotation".
>>   * I replaced pSmi->ShadowPitch with pSmi->screenStride, it seems it makes more sense because the lower word of ShadowPitch may change independently.
>>   * I moved the SMI_DEDataFormat to smi_accel.c because it seems it is a piece of code repeated many times in the driver.
>>   * At some places, it is assumed the framebuffer is at FBOffset: when using a shadow framebuffer, FBOffset is the location of the on-screen framebuffer (0 should be used). This made e.g. EXA completly useless with ShadowFB enabled (it crashed).
>>   * In the FBManager initialization, I have replaced xf86InitFBManager with xf86InitFBManagerRegion to reserve some additional space as screen fb: it's unlikely to be the case, but a less efficient alignment in the rotated mode could make the rotated mode need more memory than the unrotated one.
>>     This is not a problem with EXA as the offscreen memory parameters can be easily modified when doing the rotation.
>>   * In SMI_RefreshArea it's assumed that some DE registers are already in some state, this is specially not true when using EXA.
>>   * SMI_ValidMode rejects a mode with different dimensions than the panel. This seems to work now.
>>  - I've messed a little with the EXA uts/dfs code, but I haven't achieved too much... To get it working I had to do some changes:
>>    * The DTS code uses the screen Bpp inestead of the pixmap Bpp... this gives some problems when using pixmaps with different depth to the screen.
>>    * aligned_pitch was computed from src_pitch inestead of the pixmap width.
>>    * When writing the target coordinates to the DE registers, it does y*0xFFFF inestead of y & 0xFFFF.
>>    I also renamed source_pitch to src_pixelpitch as it is very confusing to have src_pitch and source_pitch.
>>    It isn't necessary to call WaitQueue before copying each scanline, but it seems it almost doesn't affect performance.
>>  - Finally, I wanted to have XV with the RandRRotation option enabled.
>>    As it doesn't seem feasible to rotate the video, I did some modifications at SMI_PutImage and SMI_ClipVideo to make PutImage work (incorrectly) with rotation enabled. The image is displayed unrotated. Do you think this is worse than having no XV at all? Maybe it could be useful...
>> I have splitted the patch ( ) to make testing easier, but i don't think they are completely independent:


More information about the xorg mailing list