kdrive: Extract common part of fbdevPutColors and fbdevEnable
Put framebuffer colormap updating code in separate function for brevity. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
This commit is contained in:
parent
7ee14154b2
commit
dbaab9759b
|
@ -651,6 +651,21 @@ fbdevPreserve (KdCardInfo *card)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
fbdevUpdateFbColormap(FbdevPriv *priv, int minidx, int maxidx)
|
||||||
|
{
|
||||||
|
struct fb_cmap cmap;
|
||||||
|
|
||||||
|
cmap.start = minidx;
|
||||||
|
cmap.len = maxidx - minidx + 1;
|
||||||
|
cmap.red = &priv->red[minidx];
|
||||||
|
cmap.green = &priv->green[minidx];
|
||||||
|
cmap.blue = &priv->blue[minidx];
|
||||||
|
cmap.transp = 0;
|
||||||
|
|
||||||
|
return ioctl(priv->fd, FBIOPUTCMAP, &cmap);
|
||||||
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
fbdevEnable (ScreenPtr pScreen)
|
fbdevEnable (ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
|
@ -670,7 +685,6 @@ fbdevEnable (ScreenPtr pScreen)
|
||||||
|
|
||||||
if (priv->fix.visual == FB_VISUAL_DIRECTCOLOR)
|
if (priv->fix.visual == FB_VISUAL_DIRECTCOLOR)
|
||||||
{
|
{
|
||||||
struct fb_cmap cmap;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0;
|
for (i = 0;
|
||||||
|
@ -682,13 +696,8 @@ fbdevEnable (ScreenPtr pScreen)
|
||||||
priv->green[i] = i * 65535 / ((1 << priv->var.green.length) - 1);
|
priv->green[i] = i * 65535 / ((1 << priv->var.green.length) - 1);
|
||||||
priv->blue[i] = i * 65535 / ((1 << priv->var.blue.length) - 1);
|
priv->blue[i] = i * 65535 / ((1 << priv->var.blue.length) - 1);
|
||||||
}
|
}
|
||||||
cmap.start = 0;
|
|
||||||
cmap.len = i;
|
fbdevUpdateFbColormap(priv, 0, i);
|
||||||
cmap.red = &priv->red[0];
|
|
||||||
cmap.green = &priv->green[0];
|
|
||||||
cmap.blue = &priv->blue[0];
|
|
||||||
cmap.transp = 0;
|
|
||||||
ioctl (priv->fd, FBIOPUTCMAP, &cmap);
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -744,6 +753,9 @@ fbdevCardFini (KdCardInfo *card)
|
||||||
xfree (priv);
|
xfree (priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve actual colormap and return selected n entries in pdefs.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
fbdevGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
|
fbdevGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
|
||||||
{
|
{
|
||||||
|
@ -785,12 +797,14 @@ fbdevGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Change colormap by updating n entries described in pdefs.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
fbdevPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
|
fbdevPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
|
||||||
{
|
{
|
||||||
KdScreenPriv(pScreen);
|
KdScreenPriv(pScreen);
|
||||||
FbdevPriv *priv = pScreenPriv->card->driver;
|
FbdevPriv *priv = pScreenPriv->card->driver;
|
||||||
struct fb_cmap cmap;
|
|
||||||
int p;
|
int p;
|
||||||
int min, max;
|
int min, max;
|
||||||
|
|
||||||
|
@ -808,11 +822,6 @@ fbdevPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
|
||||||
max = p;
|
max = p;
|
||||||
pdefs++;
|
pdefs++;
|
||||||
}
|
}
|
||||||
cmap.start = min;
|
|
||||||
cmap.len = max - min + 1;
|
fbdevUpdateFbColormap(priv, min, max);
|
||||||
cmap.red = &priv->red[min];
|
|
||||||
cmap.green = &priv->green[min];
|
|
||||||
cmap.blue = &priv->blue[min];
|
|
||||||
cmap.transp = 0;
|
|
||||||
ioctl (priv->fd, FBIOPUTCMAP, &cmap);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user