diff options
Diffstat (limited to 'drivers/staging/gma500/framebuffer.c')
-rw-r--r-- | drivers/staging/gma500/framebuffer.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/drivers/staging/gma500/framebuffer.c b/drivers/staging/gma500/framebuffer.c index 3f39a37456f..b00761cba14 100644 --- a/drivers/staging/gma500/framebuffer.c +++ b/drivers/staging/gma500/framebuffer.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <drm/drmP.h> | 32 | #include <drm/drmP.h> |
33 | #include <drm/drm.h> | 33 | #include <drm/drm.h> |
34 | #include <drm/drm_crtc.h> | 34 | #include <drm/drm_crtc.h> |
35 | #include <drm/drm_fb_helper.h> | ||
35 | 36 | ||
36 | #include "psb_drv.h" | 37 | #include "psb_drv.h" |
37 | #include "psb_intel_reg.h" | 38 | #include "psb_intel_reg.h" |
@@ -273,14 +274,17 @@ static struct fb_ops psbfb_unaccel_ops = { | |||
273 | */ | 274 | */ |
274 | static int psb_framebuffer_init(struct drm_device *dev, | 275 | static int psb_framebuffer_init(struct drm_device *dev, |
275 | struct psb_framebuffer *fb, | 276 | struct psb_framebuffer *fb, |
276 | struct drm_mode_fb_cmd *mode_cmd, | 277 | struct drm_mode_fb_cmd2 *mode_cmd, |
277 | struct gtt_range *gt) | 278 | struct gtt_range *gt) |
278 | { | 279 | { |
280 | u32 bpp, depth; | ||
279 | int ret; | 281 | int ret; |
280 | 282 | ||
281 | if (mode_cmd->pitch & 63) | 283 | drm_fb_get_bpp_depth(mode_cmd->pixel_format, &depth, &bpp); |
284 | |||
285 | if (mode_cmd->pitches[0] & 63) | ||
282 | return -EINVAL; | 286 | return -EINVAL; |
283 | switch (mode_cmd->bpp) { | 287 | switch (bpp) { |
284 | case 8: | 288 | case 8: |
285 | case 16: | 289 | case 16: |
286 | case 24: | 290 | case 24: |
@@ -313,7 +317,7 @@ static int psb_framebuffer_init(struct drm_device *dev, | |||
313 | 317 | ||
314 | static struct drm_framebuffer *psb_framebuffer_create | 318 | static struct drm_framebuffer *psb_framebuffer_create |
315 | (struct drm_device *dev, | 319 | (struct drm_device *dev, |
316 | struct drm_mode_fb_cmd *mode_cmd, | 320 | struct drm_mode_fb_cmd2 *mode_cmd, |
317 | struct gtt_range *gt) | 321 | struct gtt_range *gt) |
318 | { | 322 | { |
319 | struct psb_framebuffer *fb; | 323 | struct psb_framebuffer *fb; |
@@ -387,27 +391,28 @@ static int psbfb_create(struct psb_fbdev *fbdev, | |||
387 | struct fb_info *info; | 391 | struct fb_info *info; |
388 | struct drm_framebuffer *fb; | 392 | struct drm_framebuffer *fb; |
389 | struct psb_framebuffer *psbfb = &fbdev->pfb; | 393 | struct psb_framebuffer *psbfb = &fbdev->pfb; |
390 | struct drm_mode_fb_cmd mode_cmd; | 394 | struct drm_mode_fb_cmd2 mode_cmd; |
391 | struct device *device = &dev->pdev->dev; | 395 | struct device *device = &dev->pdev->dev; |
392 | int size; | 396 | int size; |
393 | int ret; | 397 | int ret; |
394 | struct gtt_range *backing; | 398 | struct gtt_range *backing; |
395 | int gtt_roll = 1; | 399 | int gtt_roll = 1; |
400 | u32 bpp, depth; | ||
396 | 401 | ||
397 | mode_cmd.width = sizes->surface_width; | 402 | mode_cmd.width = sizes->surface_width; |
398 | mode_cmd.height = sizes->surface_height; | 403 | mode_cmd.height = sizes->surface_height; |
399 | mode_cmd.bpp = sizes->surface_bpp; | 404 | bpp = sizes->surface_bpp; |
400 | 405 | ||
401 | /* No 24bit packed */ | 406 | /* No 24bit packed */ |
402 | if (mode_cmd.bpp == 24) | 407 | if (bpp == 24) |
403 | mode_cmd.bpp = 32; | 408 | bpp = 32; |
404 | 409 | ||
405 | /* Acceleration via the GTT requires pitch to be 4096 byte aligned | 410 | /* Acceleration via the GTT requires pitch to be 4096 byte aligned |
406 | (ie 1024 or 2048 pixels in normal use) */ | 411 | (ie 1024 or 2048 pixels in normal use) */ |
407 | mode_cmd.pitch = ALIGN(mode_cmd.width * ((mode_cmd.bpp + 7) / 8), 4096); | 412 | mode_cmd.pitches[0] = ALIGN(mode_cmd.width * ((bpp + 7) / 8), 4096); |
408 | mode_cmd.depth = sizes->surface_depth; | 413 | depth = sizes->surface_depth; |
409 | 414 | ||
410 | size = mode_cmd.pitch * mode_cmd.height; | 415 | size = mode_cmd.pitches[0] * mode_cmd.height; |
411 | size = ALIGN(size, PAGE_SIZE); | 416 | size = ALIGN(size, PAGE_SIZE); |
412 | 417 | ||
413 | /* Allocate the framebuffer in the GTT with stolen page backing */ | 418 | /* Allocate the framebuffer in the GTT with stolen page backing */ |
@@ -421,10 +426,10 @@ static int psbfb_create(struct psb_fbdev *fbdev, | |||
421 | 426 | ||
422 | gtt_roll = 0; /* Don't use GTT accelerated scrolling */ | 427 | gtt_roll = 0; /* Don't use GTT accelerated scrolling */ |
423 | 428 | ||
424 | mode_cmd.pitch = ALIGN(mode_cmd.width * ((mode_cmd.bpp + 7) / 8), 64); | 429 | mode_cmd.pitches[0] = ALIGN(mode_cmd.width * ((bpp + 7) / 8), 64); |
425 | mode_cmd.depth = sizes->surface_depth; | 430 | depth = sizes->surface_depth; |
426 | 431 | ||
427 | size = mode_cmd.pitch * mode_cmd.height; | 432 | size = mode_cmd.pitches[0] * mode_cmd.height; |
428 | size = ALIGN(size, PAGE_SIZE); | 433 | size = ALIGN(size, PAGE_SIZE); |
429 | 434 | ||
430 | /* Allocate the framebuffer in the GTT with stolen page | 435 | /* Allocate the framebuffer in the GTT with stolen page |
@@ -443,6 +448,8 @@ static int psbfb_create(struct psb_fbdev *fbdev, | |||
443 | } | 448 | } |
444 | info->par = fbdev; | 449 | info->par = fbdev; |
445 | 450 | ||
451 | mode_cmd.pixel_format = drm_mode_legacy_fb_format(bpp, depth); | ||
452 | |||
446 | ret = psb_framebuffer_init(dev, psbfb, &mode_cmd, backing); | 453 | ret = psb_framebuffer_init(dev, psbfb, &mode_cmd, backing); |
447 | if (ret) | 454 | if (ret) |
448 | goto out_unref; | 455 | goto out_unref; |
@@ -504,7 +511,7 @@ static int psbfb_create(struct psb_fbdev *fbdev, | |||
504 | info->apertures->ranges[0].size = dev_priv->gtt.stolen_size; | 511 | info->apertures->ranges[0].size = dev_priv->gtt.stolen_size; |
505 | } | 512 | } |
506 | 513 | ||
507 | drm_fb_helper_fill_fix(info, fb->pitch, fb->depth); | 514 | drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth); |
508 | drm_fb_helper_fill_var(info, &fbdev->psb_fb_helper, | 515 | drm_fb_helper_fill_var(info, &fbdev->psb_fb_helper, |
509 | sizes->fb_width, sizes->fb_height); | 516 | sizes->fb_width, sizes->fb_height); |
510 | 517 | ||
@@ -546,7 +553,7 @@ out_err1: | |||
546 | */ | 553 | */ |
547 | static struct drm_framebuffer *psb_user_framebuffer_create | 554 | static struct drm_framebuffer *psb_user_framebuffer_create |
548 | (struct drm_device *dev, struct drm_file *filp, | 555 | (struct drm_device *dev, struct drm_file *filp, |
549 | struct drm_mode_fb_cmd *cmd) | 556 | struct drm_mode_fb_cmd2 *cmd) |
550 | { | 557 | { |
551 | struct gtt_range *r; | 558 | struct gtt_range *r; |
552 | struct drm_gem_object *obj; | 559 | struct drm_gem_object *obj; |
@@ -555,7 +562,7 @@ static struct drm_framebuffer *psb_user_framebuffer_create | |||
555 | * Find the GEM object and thus the gtt range object that is | 562 | * Find the GEM object and thus the gtt range object that is |
556 | * to back this space | 563 | * to back this space |
557 | */ | 564 | */ |
558 | obj = drm_gem_object_lookup(dev, filp, cmd->handle); | 565 | obj = drm_gem_object_lookup(dev, filp, cmd->handles[0]); |
559 | if (obj == NULL) | 566 | if (obj == NULL) |
560 | return ERR_PTR(-ENOENT); | 567 | return ERR_PTR(-ENOENT); |
561 | 568 | ||