blitter.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2014, Patrik Jakobsson
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * Authors: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
  15. */
  16. #include "psb_drv.h"
  17. #include "blitter.h"
  18. #include "psb_reg.h"
  19. /* Wait for the blitter to be completely idle */
  20. int gma_blt_wait_idle(struct drm_psb_private *dev_priv)
  21. {
  22. unsigned long stop = jiffies + HZ;
  23. int busy = 1;
  24. /* NOP for Cedarview */
  25. if (IS_CDV(dev_priv->dev))
  26. return 0;
  27. /* First do a quick check */
  28. if ((PSB_RSGX32(PSB_CR_2D_SOCIF) == _PSB_C2_SOCIF_EMPTY) &&
  29. ((PSB_RSGX32(PSB_CR_2D_BLIT_STATUS) & _PSB_C2B_STATUS_BUSY) == 0))
  30. return 0;
  31. do {
  32. busy = (PSB_RSGX32(PSB_CR_2D_SOCIF) != _PSB_C2_SOCIF_EMPTY);
  33. } while (busy && !time_after_eq(jiffies, stop));
  34. if (busy)
  35. return -EBUSY;
  36. do {
  37. busy = ((PSB_RSGX32(PSB_CR_2D_BLIT_STATUS) &
  38. _PSB_C2B_STATUS_BUSY) != 0);
  39. } while (busy && !time_after_eq(jiffies, stop));
  40. /* If still busy, we probably have a hang */
  41. return (busy) ? -EBUSY : 0;
  42. }