summaryrefslogtreecommitdiff
path: root/linux-core
diff options
context:
space:
mode:
Diffstat (limited to 'linux-core')
-rw-r--r--linux-core/intel_fb.c438
1 files changed, 221 insertions, 217 deletions
diff --git a/linux-core/intel_fb.c b/linux-core/intel_fb.c
index 7df1525a..73ad35c7 100644
--- a/linux-core/intel_fb.c
+++ b/linux-core/intel_fb.c
@@ -47,24 +47,25 @@
struct intelfb_par {
struct drm_device *dev;
struct drm_crtc *crtc;
- struct drm_display_mode *fb_mode;
+ struct drm_display_mode *fb_mode;
struct drm_framebuffer *fb;
+ struct drm_mode_set set;
};
/*
static int
var_to_refresh(const struct fb_var_screeninfo *var)
{
int xtot = var->xres + var->left_margin + var->right_margin +
- var->hsync_len;
+ var->hsync_len;
int ytot = var->yres + var->upper_margin + var->lower_margin +
- var->vsync_len;
+ var->vsync_len;
return (1000000000 / var->pixclock * 1000 + 500) / xtot / ytot;
}*/
static int intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
- unsigned blue, unsigned transp,
- struct fb_info *info)
+ unsigned blue, unsigned transp,
+ struct fb_info *info)
{
struct intelfb_par *par = info->par;
struct drm_framebuffer *fb = par->fb;
@@ -82,9 +83,9 @@ static int intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
if (regno < 16) {
switch (fb->depth) {
case 15:
- fb->pseudo_palette[regno] = ((red & 0xf800) >> 1) |
+ fb->pseudo_palette[regno] = ((red & 0xf800) >> 1) |
((green & 0xf800) >> 6) |
- ((blue & 0xf800) >> 11);
+ ((blue & 0xf800) >> 11);
break;
case 16:
fb->pseudo_palette[regno] = (red & 0xf800) |
@@ -94,7 +95,7 @@ static int intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
case 24:
case 32:
fb->pseudo_palette[regno] = ((red & 0xff00) << 8) |
- (green & 0xff00) |
+ (green & 0xff00) |
((blue & 0xff00) >> 8);
break;
}
@@ -104,114 +105,114 @@ static int intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
}
static int intelfb_check_var(struct fb_var_screeninfo *var,
- struct fb_info *info)
+ struct fb_info *info)
{
- struct intelfb_par *par = info->par;
- /*struct drm_device *dev = par->dev;*/
+ struct intelfb_par *par = info->par;
+ /*struct drm_device *dev = par->dev;*/
struct drm_framebuffer *fb = par->fb;
- /*struct drm_output *output;*/
- int depth/*, found = 0*/;
-
- if (!var->pixclock)
- return -EINVAL;
-
- /* Need to resize the fb object !!! */
- if (var->xres > fb->width || var->yres > fb->height) {
- DRM_ERROR("Requested width/height is greater than current fb object %dx%d > %dx%d\n",var->xres,var->yres,fb->width,fb->height);
- DRM_ERROR("Need resizing code.\n");
- return -EINVAL;
- }
-
- switch (var->bits_per_pixel) {
- case 16:
- depth = (var->green.length == 6) ? 16 : 15;
- break;
- case 32:
- depth = (var->transp.length > 0) ? 32 : 24;
- break;
- default:
- depth = var->bits_per_pixel;
- break;
- }
-
- switch (depth) {
- case 8:
- var->red.offset = 0;
- var->green.offset = 0;
- var->blue.offset = 0;
- var->red.length = 8;
- var->green.length = 8;
- var->blue.length = 8;
- var->transp.length = 0;
- var->transp.offset = 0;
- break;
- case 15:
- var->red.offset = 10;
- var->green.offset = 5;
- var->blue.offset = 0;
- var->red.length = 5;
- var->green.length = 5;
- var->blue.length = 5;
- var->transp.length = 1;
- var->transp.offset = 15;
- break;
- case 16:
- var->red.offset = 11;
- var->green.offset = 5;
- var->blue.offset = 0;
- var->red.length = 5;
- var->green.length = 6;
- var->blue.length = 5;
- var->transp.length = 0;
- var->transp.offset = 0;
- break;
- case 24:
- var->red.offset = 16;
- var->green.offset = 8;
- var->blue.offset = 0;
- var->red.length = 8;
- var->green.length = 8;
- var->blue.length = 8;
- var->transp.length = 0;
- var->transp.offset = 0;
- break;
- case 32:
- var->red.offset = 16;
- var->green.offset = 8;
- var->blue.offset = 0;
- var->red.length = 8;
- var->green.length = 8;
- var->blue.length = 8;
- var->transp.length = 8;
- var->transp.offset = 24;
- break;
- default:
- return -EINVAL;
- }
+ /*struct drm_output *output;*/
+ int depth/*, found = 0*/;
+
+ if (!var->pixclock)
+ return -EINVAL;
+
+ /* Need to resize the fb object !!! */
+ if (var->xres > fb->width || var->yres > fb->height) {
+ DRM_ERROR("Requested width/height is greater than current fb object %dx%d > %dx%d\n",var->xres,var->yres,fb->width,fb->height);
+ DRM_ERROR("Need resizing code.\n");
+ return -EINVAL;
+ }
+
+ switch (var->bits_per_pixel) {
+ case 16:
+ depth = (var->green.length == 6) ? 16 : 15;
+ break;
+ case 32:
+ depth = (var->transp.length > 0) ? 32 : 24;
+ break;
+ default:
+ depth = var->bits_per_pixel;
+ break;
+ }
+
+ switch (depth) {
+ case 8:
+ var->red.offset = 0;
+ var->green.offset = 0;
+ var->blue.offset = 0;
+ var->red.length = 8;
+ var->green.length = 8;
+ var->blue.length = 8;
+ var->transp.length = 0;
+ var->transp.offset = 0;
+ break;
+ case 15:
+ var->red.offset = 10;
+ var->green.offset = 5;
+ var->blue.offset = 0;
+ var->red.length = 5;
+ var->green.length = 5;
+ var->blue.length = 5;
+ var->transp.length = 1;
+ var->transp.offset = 15;
+ break;
+ case 16:
+ var->red.offset = 11;
+ var->green.offset = 5;
+ var->blue.offset = 0;
+ var->red.length = 5;
+ var->green.length = 6;
+ var->blue.length = 5;
+ var->transp.length = 0;
+ var->transp.offset = 0;
+ break;
+ case 24:
+ var->red.offset = 16;
+ var->green.offset = 8;
+ var->blue.offset = 0;
+ var->red.length = 8;
+ var->green.length = 8;
+ var->blue.length = 8;
+ var->transp.length = 0;
+ var->transp.offset = 0;
+ break;
+ case 32:
+ var->red.offset = 16;
+ var->green.offset = 8;
+ var->blue.offset = 0;
+ var->red.length = 8;
+ var->green.length = 8;
+ var->blue.length = 8;
+ var->transp.length = 8;
+ var->transp.offset = 24;
+ break;
+ default:
+ return -EINVAL;
+ }
#if 0
- /* Here we walk the output mode list and look for modes. If we haven't
- * got it, then bail. Not very nice, so this is disabled.
- * In the set_par code, we create our mode based on the incoming
- * parameters. Nicer, but may not be desired by some.
- */
- list_for_each_entry(output, &dev->mode_config.output_list, head) {
- if (output->crtc == par->crtc)
- break;
- }
-
- list_for_each_entry(drm_mode, &output->modes, head) {
- if (drm_mode->hdisplay == var->xres &&
- drm_mode->vdisplay == var->yres &&
- (((PICOS2KHZ(var->pixclock))/1000) >= ((drm_mode->clock/1000)-1)) &&
- (((PICOS2KHZ(var->pixclock))/1000) <= ((drm_mode->clock/1000)+1))) {
+ /* Here we walk the output mode list and look for modes. If we haven't
+ * got it, then bail. Not very nice, so this is disabled.
+ * In the set_par code, we create our mode based on the incoming
+ * parameters. Nicer, but may not be desired by some.
+ */
+ list_for_each_entry(output, &dev->mode_config.output_list, head) {
+ if (output->crtc == par->crtc)
+ break;
+ }
+
+ list_for_each_entry(drm_mode, &output->modes, head) {
+ if (drm_mode->hdisplay == var->xres &&
+ drm_mode->vdisplay == var->yres &&
+ (((PICOS2KHZ(var->pixclock))/1000) >= ((drm_mode->clock/1000)-1)) &&
+ (((PICOS2KHZ(var->pixclock))/1000) <= ((drm_mode->clock/1000)+1))) {
found = 1;
break;
}
}
- if (!found)
- return -EINVAL;
+ if (!found)
+ return -EINVAL;
#endif
return 0;
@@ -224,68 +225,68 @@ static int intelfb_set_par(struct fb_info *info)
struct intelfb_par *par = info->par;
struct drm_framebuffer *fb = par->fb;
struct drm_device *dev = par->dev;
- struct drm_display_mode *drm_mode, *search_mode;
- struct drm_output *output = NULL;
- struct fb_var_screeninfo *var = &info->var;
+ struct drm_display_mode *drm_mode, *search_mode;
+ struct drm_output *output = NULL;
+ struct fb_var_screeninfo *var = &info->var;
int found = 0;
int changed = 0;
DRM_DEBUG("\n");
- switch (var->bits_per_pixel) {
- case 16:
- fb->depth = (var->green.length == 6) ? 16 : 15;
- break;
- case 32:
- fb->depth = (var->transp.length > 0) ? 32 : 24;
- break;
- default:
- fb->depth = var->bits_per_pixel;
- break;
- }
+ switch (var->bits_per_pixel) {
+ case 16:
+ fb->depth = (var->green.length == 6) ? 16 : 15;
+ break;
+ case 32:
+ fb->depth = (var->transp.length > 0) ? 32 : 24;
+ break;
+ default:
+ fb->depth = var->bits_per_pixel;
+ break;
+ }
- fb->bits_per_pixel = var->bits_per_pixel;
+ fb->bits_per_pixel = var->bits_per_pixel;
- info->fix.line_length = fb->pitch;
- info->fix.smem_len = info->fix.line_length * fb->height;
- info->fix.visual = (fb->depth == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
+ info->fix.line_length = fb->pitch;
+ info->fix.smem_len = info->fix.line_length * fb->height;
+ info->fix.visual = (fb->depth == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
- info->screen_size = info->fix.smem_len; /* ??? */
+ info->screen_size = info->fix.smem_len; /* ??? */
/* create a drm mode */
- drm_mode = drm_mode_create(dev);
- drm_mode->hdisplay = var->xres;
- drm_mode->hsync_start = drm_mode->hdisplay + var->right_margin;
- drm_mode->hsync_end = drm_mode->hsync_start + var->hsync_len;
- drm_mode->htotal = drm_mode->hsync_end + var->left_margin;
- drm_mode->vdisplay = var->yres;
- drm_mode->vsync_start = drm_mode->vdisplay + var->lower_margin;
- drm_mode->vsync_end = drm_mode->vsync_start + var->vsync_len;
- drm_mode->vtotal = drm_mode->vsync_end + var->upper_margin;
- drm_mode->clock = PICOS2KHZ(var->pixclock);
- drm_mode->vrefresh = drm_mode_vrefresh(drm_mode);
+ drm_mode = drm_mode_create(dev);
+ drm_mode->hdisplay = var->xres;
+ drm_mode->hsync_start = drm_mode->hdisplay + var->right_margin;
+ drm_mode->hsync_end = drm_mode->hsync_start + var->hsync_len;
+ drm_mode->htotal = drm_mode->hsync_end + var->left_margin;
+ drm_mode->vdisplay = var->yres;
+ drm_mode->vsync_start = drm_mode->vdisplay + var->lower_margin;
+ drm_mode->vsync_end = drm_mode->vsync_start + var->vsync_len;
+ drm_mode->vtotal = drm_mode->vsync_end + var->upper_margin;
+ drm_mode->clock = PICOS2KHZ(var->pixclock);
+ drm_mode->vrefresh = drm_mode_vrefresh(drm_mode);
drm_mode->flags = 0;
drm_mode->flags |= var->sync & FB_SYNC_HOR_HIGH_ACT ? V_PHSYNC : V_NHSYNC;
drm_mode->flags |= var->sync & FB_SYNC_VERT_HIGH_ACT ? V_PVSYNC : V_NVSYNC;
- drm_mode_set_name(drm_mode);
+ drm_mode_set_name(drm_mode);
drm_mode_set_crtcinfo(drm_mode, CRTC_INTERLACE_HALVE_V);
found = 0;
- list_for_each_entry(output, &dev->mode_config.output_list, head) {
- if (output->crtc == par->crtc){
+ list_for_each_entry(output, &dev->mode_config.output_list, head) {
+ if (output->crtc == par->crtc){
found = 1;
- break;
+ break;
}
- }
+ }
/* no output bound, bail */
if (!found)
return -EINVAL;
found = 0;
- drm_mode_debug_printmodeline(dev, drm_mode);
- list_for_each_entry(search_mode, &output->modes, head) {
+ drm_mode_debug_printmodeline(dev, drm_mode);
+ list_for_each_entry(search_mode, &output->modes, head) {
drm_mode_debug_printmodeline(dev, search_mode);
if (drm_mode_equal(drm_mode, search_mode)) {
drm_mode_destroy(dev, drm_mode);
@@ -296,8 +297,8 @@ static int intelfb_set_par(struct fb_info *info)
}
/* If we didn't find a matching mode that exists on our output,
- * create a new attachment for the incoming user specified mode
- */
+ * create a new attachment for the incoming user specified mode
+ */
if (!found) {
if (par->fb_mode) {
/* this also destroys the mode */
@@ -318,7 +319,7 @@ static int intelfb_set_par(struct fb_info *info)
if (par->crtc->x != var->xoffset || par->crtc->y != var->yoffset)
changed = 1;
-
+
drm_mode_debug_printmodeline(dev, drm_mode);
drm_mode_debug_printmodeline(dev, &par->crtc->mode);
if (!drm_mode_equal(drm_mode, &par->crtc->mode))
@@ -333,9 +334,9 @@ static int intelfb_set_par(struct fb_info *info)
#if 0
static void intelfb_copyarea(struct fb_info *info,
- const struct fb_copyarea *region)
+ const struct fb_copyarea *region)
{
- struct intelfb_par *par = info->par;
+ struct intelfb_par *par = info->par;
struct drm_device *dev = par->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
u32 src_x1, src_y1, dst_x1, dst_y1, dst_x2, dst_y2, offset;
@@ -380,7 +381,7 @@ static void intelfb_copyarea(struct fb_info *info,
void intelfb_imageblit(struct fb_info *info, const struct fb_image *image)
{
- struct intelfb_par *par = info->par;
+ struct intelfb_par *par = info->par;
struct drm_device *dev = par->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
u32 cmd, rop_pitch_depth, tmp;
@@ -397,9 +398,9 @@ void intelfb_imageblit(struct fb_info *info, const struct fb_image *image)
nbytes *= image->height;
/*
- * Check if the glyph data exceeds the immediate mode limit.
- * It would take a large font (1K pixels) to hit this limit.
- */
+ * Check if the glyph data exceeds the immediate mode limit.
+ * It would take a large font (1K pixels) to hit this limit.
+ */
if (nbytes > 128 || image->depth != 1)
return cfb_imageblit(info, image);
@@ -407,13 +408,13 @@ void intelfb_imageblit(struct fb_info *info, const struct fb_image *image)
ndwords = ROUND_UP_TO(nbytes, 4) / 4;
/*
- * Ring has to be padded to a quad word. But because the command starts
- with 7 bytes, pad only if there is an even number of ndwords
- */
+ * Ring has to be padded to a quad word. But because the command starts
+ with 7 bytes, pad only if there is an even number of ndwords
+ */
pad = !(ndwords % 2);
DRM_DEBUG("imageblit %dx%dx%d to (%d,%d)\n", image->width,
- image->height, image->depth, image->dx, image->dy);
+ image->height, image->depth, image->dx, image->dy);
DRM_DEBUG("nbytes: %d, ndwords: %d, pad: %d\n", nbytes, ndwords, pad);
tmp = (XY_MONO_SRC_COPY_IMM_BLT & 0xff) + ndwords;
@@ -477,7 +478,7 @@ void intelfb_imageblit(struct fb_info *info, const struct fb_image *image)
}
#endif
static int intelfb_pan_display(struct fb_var_screeninfo *var,
- struct fb_info *info)
+ struct fb_info *info)
{
struct intelfb_par *par = info->par;
struct drm_crtc *crtc = par->crtc;
@@ -505,11 +506,11 @@ static int intelfb_pan_display(struct fb_var_screeninfo *var,
static struct fb_ops intelfb_ops = {
.owner = THIS_MODULE,
- // .fb_open = intelfb_open,
- // .fb_read = intelfb_read,
- // .fb_write = intelfb_write,
- // .fb_release = intelfb_release,
- // .fb_ioctl = intelfb_ioctl,
+ //.fb_open = intelfb_open,
+ //.fb_read = intelfb_read,
+ //.fb_write = intelfb_write,
+ //.fb_release = intelfb_release,
+ //.fb_ioctl = intelfb_ioctl,
.fb_check_var = intelfb_check_var,
.fb_set_par = intelfb_set_par,
.fb_setcolreg = intelfb_setcolreg,
@@ -590,14 +591,14 @@ int intelfb_probe(struct drm_device *dev, struct drm_crtc *crtc)
fb->pitch = fb->width * ((fb->bits_per_pixel + 1) / 8);
fb->depth = 24;
ret = drm_buffer_object_create(dev, fb->pitch * fb->height,
- drm_bo_type_kernel,
- DRM_BO_FLAG_READ |
- DRM_BO_FLAG_WRITE |
- DRM_BO_FLAG_MEM_TT |
- DRM_BO_FLAG_MEM_VRAM |
- DRM_BO_FLAG_NO_EVICT,
- DRM_BO_HINT_DONT_FENCE, 0, 0,
- &fbo);
+ drm_bo_type_kernel,
+ DRM_BO_FLAG_READ |
+ DRM_BO_FLAG_WRITE |
+ DRM_BO_FLAG_MEM_TT |
+ DRM_BO_FLAG_MEM_VRAM |
+ DRM_BO_FLAG_NO_EVICT,
+ DRM_BO_HINT_DONT_FENCE, 0, 0,
+ &fbo);
if (ret || !fbo) {
printk(KERN_ERR "failed to allocate framebuffer\n");
drm_framebuffer_destroy(fb);
@@ -607,7 +608,7 @@ int intelfb_probe(struct drm_device *dev, struct drm_crtc *crtc)
fb->bo = fbo;
printk("allocated %dx%d fb: 0x%08lx, bo %p\n", fb->width,
- fb->height, fbo->offset, fbo);
+ fb->height, fbo->offset, fbo);
fb->fbdev = info;
@@ -645,9 +646,9 @@ int intelfb_probe(struct drm_device *dev, struct drm_crtc *crtc)
info->flags = FBINFO_DEFAULT;
ret = drm_bo_kmap(fb->bo, 0, fb->bo->num_pages, &fb->kmap);
- if (ret)
- DRM_ERROR("error mapping fb: %d\n", ret);
-
+ if (ret)
+ DRM_ERROR("error mapping fb: %d\n", ret);
+
info->screen_base = fb->kmap.virtual;
info->screen_size = info->fix.smem_len; /* FIXME */
info->pseudo_palette = fb->pseudo_palette;
@@ -660,13 +661,13 @@ int intelfb_probe(struct drm_device *dev, struct drm_crtc *crtc)
info->var.height = -1;
info->var.width = -1;
- info->var.xres = mode->hdisplay;
- info->var.right_margin = mode->hsync_start - mode->hdisplay;
- info->var.hsync_len = mode->hsync_end - mode->hsync_start;
- info->var.left_margin = mode->htotal - mode->hsync_end;
- info->var.yres = mode->vdisplay;
- info->var.lower_margin = mode->vsync_start - mode->vdisplay;
- info->var.vsync_len = mode->vsync_end - mode->vsync_start;
+ info->var.xres = mode->hdisplay;
+ info->var.right_margin = mode->hsync_start - mode->hdisplay;
+ info->var.hsync_len = mode->hsync_end - mode->hsync_start;
+ info->var.left_margin = mode->htotal - mode->hsync_end;
+ info->var.yres = mode->vdisplay;
+ info->var.lower_margin = mode->vsync_start - mode->vdisplay;
+ info->var.vsync_len = mode->vsync_end - mode->vsync_start;
info->var.upper_margin = mode->vtotal - mode->vsync_end;
info->var.pixclock = KHZ2PICOS(mode->clock);
@@ -693,48 +694,51 @@ int intelfb_probe(struct drm_device *dev, struct drm_crtc *crtc)
DRM_DEBUG(" pitch is %d\n", fb->pitch);
switch(fb->depth) {
case 8:
- info->var.red.offset = 0;
- info->var.green.offset = 0;
- info->var.blue.offset = 0;
- info->var.red.length = 8; /* 8bit DAC */
- info->var.green.length = 8;
- info->var.blue.length = 8;
- info->var.transp.offset = 0;
- info->var.transp.length = 0;
- break;
+ info->var.red.offset = 0;
+ info->var.green.offset = 0;
+ info->var.blue.offset = 0;
+ info->var.red.length = 8; /* 8bit DAC */
+ info->var.green.length = 8;
+ info->var.blue.length = 8;
+ info->var.transp.offset = 0;
+ info->var.transp.length = 0;
+ break;
case 15:
- info->var.red.offset = 10;
- info->var.green.offset = 5;
- info->var.blue.offset = 0;
- info->var.red.length = info->var.green.length =
- info->var.blue.length = 5;
- info->var.transp.offset = 15;
- info->var.transp.length = 1;
- break;
+ info->var.red.offset = 10;
+ info->var.green.offset = 5;
+ info->var.blue.offset = 0;
+ info->var.red.length = 5;
+ info->var.green.length = 5;
+ info->var.blue.length = 5;
+ info->var.transp.offset = 15;
+ info->var.transp.length = 1;
+ break;
case 16:
- info->var.red.offset = 11;
- info->var.green.offset = 5;
- info->var.blue.offset = 0;
- info->var.red.length = 5;
- info->var.green.length = 6;
- info->var.blue.length = 5;
- info->var.transp.offset = 0;
+ info->var.red.offset = 11;
+ info->var.green.offset = 5;
+ info->var.blue.offset = 0;
+ info->var.red.length = 5;
+ info->var.green.length = 6;
+ info->var.blue.length = 5;
+ info->var.transp.offset = 0;
break;
case 24:
- info->var.red.offset = 16;
- info->var.green.offset = 8;
- info->var.blue.offset = 0;
- info->var.red.length = info->var.green.length =
- info->var.blue.length = 8;
- info->var.transp.offset = 0;
- info->var.transp.length = 0;
- break;
+ info->var.red.offset = 16;
+ info->var.green.offset = 8;
+ info->var.blue.offset = 0;
+ info->var.red.length = 8;
+ info->var.green.length = 8;
+ info->var.blue.length = 8;
+ info->var.transp.offset = 0;
+ info->var.transp.length = 0;
+ break;
case 32:
info->var.red.offset = 16;
info->var.green.offset = 8;
info->var.blue.offset = 0;
- info->var.red.length = info->var.green.length =
- info->var.blue.length = 8;
+ info->var.red.length = 8;
+ info->var.green.length = 8;
+ info->var.blue.length = 8;
info->var.transp.offset = 24;
info->var.transp.length = 8;
break;
@@ -746,7 +750,7 @@ int intelfb_probe(struct drm_device *dev, struct drm_crtc *crtc)
return -EINVAL;
printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node,
- info->fix.id);
+ info->fix.id);
return 0;
}
EXPORT_SYMBOL(intelfb_probe);