diff options
author | Patrik Jakobsson <patrik.r.jakobsson@gmail.com> | 2013-07-10 17:48:13 -0400 |
---|---|---|
committer | Patrik Jakobsson <patrik.r.jakobsson@gmail.com> | 2013-07-23 19:47:28 -0400 |
commit | 561573bf69f71c67e6d807efef91c7cf11637817 (patch) | |
tree | f0dc508e5e3934e6065b2c482aadbffc93712396 | |
parent | 04416625f9264d6a2322cb919fa4b5b2bf72b94f (diff) |
drm/gma500/psb: Convert to generic cursor funcs
Signed-off-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
-rw-r--r-- | drivers/gpu/drm/gma500/psb_intel_display.c | 157 |
1 files changed, 2 insertions, 155 deletions
diff --git a/drivers/gpu/drm/gma500/psb_intel_display.c b/drivers/gpu/drm/gma500/psb_intel_display.c index f4d308f918e3..1e6a357a245e 100644 --- a/drivers/gpu/drm/gma500/psb_intel_display.c +++ b/drivers/gpu/drm/gma500/psb_intel_display.c | |||
@@ -434,159 +434,6 @@ static void psb_intel_crtc_restore(struct drm_crtc *crtc) | |||
434 | REG_WRITE(paletteReg + (i << 2), crtc_state->savePalette[i]); | 434 | REG_WRITE(paletteReg + (i << 2), crtc_state->savePalette[i]); |
435 | } | 435 | } |
436 | 436 | ||
437 | static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc, | ||
438 | struct drm_file *file_priv, | ||
439 | uint32_t handle, | ||
440 | uint32_t width, uint32_t height) | ||
441 | { | ||
442 | struct drm_device *dev = crtc->dev; | ||
443 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
444 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | ||
445 | int pipe = psb_intel_crtc->pipe; | ||
446 | uint32_t control = (pipe == 0) ? CURACNTR : CURBCNTR; | ||
447 | uint32_t base = (pipe == 0) ? CURABASE : CURBBASE; | ||
448 | uint32_t temp; | ||
449 | size_t addr = 0; | ||
450 | struct gtt_range *gt; | ||
451 | struct gtt_range *cursor_gt = psb_intel_crtc->cursor_gt; | ||
452 | struct drm_gem_object *obj; | ||
453 | void *tmp_dst, *tmp_src; | ||
454 | int ret = 0, i, cursor_pages; | ||
455 | |||
456 | /* if we want to turn of the cursor ignore width and height */ | ||
457 | if (!handle) { | ||
458 | /* turn off the cursor */ | ||
459 | temp = CURSOR_MODE_DISABLE; | ||
460 | |||
461 | if (gma_power_begin(dev, false)) { | ||
462 | REG_WRITE(control, temp); | ||
463 | REG_WRITE(base, 0); | ||
464 | gma_power_end(dev); | ||
465 | } | ||
466 | |||
467 | /* Unpin the old GEM object */ | ||
468 | if (psb_intel_crtc->cursor_obj) { | ||
469 | gt = container_of(psb_intel_crtc->cursor_obj, | ||
470 | struct gtt_range, gem); | ||
471 | psb_gtt_unpin(gt); | ||
472 | drm_gem_object_unreference(psb_intel_crtc->cursor_obj); | ||
473 | psb_intel_crtc->cursor_obj = NULL; | ||
474 | } | ||
475 | |||
476 | return 0; | ||
477 | } | ||
478 | |||
479 | /* Currently we only support 64x64 cursors */ | ||
480 | if (width != 64 || height != 64) { | ||
481 | dev_dbg(dev->dev, "we currently only support 64x64 cursors\n"); | ||
482 | return -EINVAL; | ||
483 | } | ||
484 | |||
485 | obj = drm_gem_object_lookup(dev, file_priv, handle); | ||
486 | if (!obj) | ||
487 | return -ENOENT; | ||
488 | |||
489 | if (obj->size < width * height * 4) { | ||
490 | dev_dbg(dev->dev, "buffer is to small\n"); | ||
491 | ret = -ENOMEM; | ||
492 | goto unref_cursor; | ||
493 | } | ||
494 | |||
495 | gt = container_of(obj, struct gtt_range, gem); | ||
496 | |||
497 | /* Pin the memory into the GTT */ | ||
498 | ret = psb_gtt_pin(gt); | ||
499 | if (ret) { | ||
500 | dev_err(dev->dev, "Can not pin down handle 0x%x\n", handle); | ||
501 | goto unref_cursor; | ||
502 | } | ||
503 | |||
504 | if (dev_priv->ops->cursor_needs_phys) { | ||
505 | if (cursor_gt == NULL) { | ||
506 | dev_err(dev->dev, "No hardware cursor mem available"); | ||
507 | ret = -ENOMEM; | ||
508 | goto unref_cursor; | ||
509 | } | ||
510 | |||
511 | /* Prevent overflow */ | ||
512 | if (gt->npage > 4) | ||
513 | cursor_pages = 4; | ||
514 | else | ||
515 | cursor_pages = gt->npage; | ||
516 | |||
517 | /* Copy the cursor to cursor mem */ | ||
518 | tmp_dst = dev_priv->vram_addr + cursor_gt->offset; | ||
519 | for (i = 0; i < cursor_pages; i++) { | ||
520 | tmp_src = kmap(gt->pages[i]); | ||
521 | memcpy(tmp_dst, tmp_src, PAGE_SIZE); | ||
522 | kunmap(gt->pages[i]); | ||
523 | tmp_dst += PAGE_SIZE; | ||
524 | } | ||
525 | |||
526 | addr = psb_intel_crtc->cursor_addr; | ||
527 | } else { | ||
528 | addr = gt->offset; /* Or resource.start ??? */ | ||
529 | psb_intel_crtc->cursor_addr = addr; | ||
530 | } | ||
531 | |||
532 | temp = 0; | ||
533 | /* set the pipe for the cursor */ | ||
534 | temp |= (pipe << 28); | ||
535 | temp |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; | ||
536 | |||
537 | if (gma_power_begin(dev, false)) { | ||
538 | REG_WRITE(control, temp); | ||
539 | REG_WRITE(base, addr); | ||
540 | gma_power_end(dev); | ||
541 | } | ||
542 | |||
543 | /* unpin the old bo */ | ||
544 | if (psb_intel_crtc->cursor_obj) { | ||
545 | gt = container_of(psb_intel_crtc->cursor_obj, | ||
546 | struct gtt_range, gem); | ||
547 | psb_gtt_unpin(gt); | ||
548 | drm_gem_object_unreference(psb_intel_crtc->cursor_obj); | ||
549 | } | ||
550 | |||
551 | psb_intel_crtc->cursor_obj = obj; | ||
552 | return ret; | ||
553 | |||
554 | unref_cursor: | ||
555 | drm_gem_object_unreference(obj); | ||
556 | return ret; | ||
557 | } | ||
558 | |||
559 | static int psb_intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) | ||
560 | { | ||
561 | struct drm_device *dev = crtc->dev; | ||
562 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | ||
563 | int pipe = psb_intel_crtc->pipe; | ||
564 | uint32_t temp = 0; | ||
565 | uint32_t addr; | ||
566 | |||
567 | |||
568 | if (x < 0) { | ||
569 | temp |= (CURSOR_POS_SIGN << CURSOR_X_SHIFT); | ||
570 | x = -x; | ||
571 | } | ||
572 | if (y < 0) { | ||
573 | temp |= (CURSOR_POS_SIGN << CURSOR_Y_SHIFT); | ||
574 | y = -y; | ||
575 | } | ||
576 | |||
577 | temp |= ((x & CURSOR_POS_MASK) << CURSOR_X_SHIFT); | ||
578 | temp |= ((y & CURSOR_POS_MASK) << CURSOR_Y_SHIFT); | ||
579 | |||
580 | addr = psb_intel_crtc->cursor_addr; | ||
581 | |||
582 | if (gma_power_begin(dev, false)) { | ||
583 | REG_WRITE((pipe == 0) ? CURAPOS : CURBPOS, temp); | ||
584 | REG_WRITE((pipe == 0) ? CURABASE : CURBBASE, addr); | ||
585 | gma_power_end(dev); | ||
586 | } | ||
587 | return 0; | ||
588 | } | ||
589 | |||
590 | static int psb_crtc_set_config(struct drm_mode_set *set) | 437 | static int psb_crtc_set_config(struct drm_mode_set *set) |
591 | { | 438 | { |
592 | int ret; | 439 | int ret; |
@@ -739,8 +586,8 @@ const struct drm_crtc_helper_funcs psb_intel_helper_funcs = { | |||
739 | const struct drm_crtc_funcs psb_intel_crtc_funcs = { | 586 | const struct drm_crtc_funcs psb_intel_crtc_funcs = { |
740 | .save = psb_intel_crtc_save, | 587 | .save = psb_intel_crtc_save, |
741 | .restore = psb_intel_crtc_restore, | 588 | .restore = psb_intel_crtc_restore, |
742 | .cursor_set = psb_intel_crtc_cursor_set, | 589 | .cursor_set = gma_crtc_cursor_set, |
743 | .cursor_move = psb_intel_crtc_cursor_move, | 590 | .cursor_move = gma_crtc_cursor_move, |
744 | .gamma_set = gma_crtc_gamma_set, | 591 | .gamma_set = gma_crtc_gamma_set, |
745 | .set_config = psb_crtc_set_config, | 592 | .set_config = psb_crtc_set_config, |
746 | .destroy = gma_crtc_destroy, | 593 | .destroy = gma_crtc_destroy, |