disp_utils.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include <linux/kthread.h>
  2. /* #include <linux/rtpm_prio.h> */
  3. #include <linux/vmalloc.h>
  4. #include <linux/semaphore.h>
  5. #include <linux/time.h>
  6. #include "m4u.h"
  7. #include <linux/delay.h>
  8. #include <linux/slab.h>
  9. #include "disp_drv_log.h"
  10. #include "disp_utils.h"
  11. int disp_sw_mutex_lock(struct mutex *m)
  12. {
  13. mutex_lock(m);
  14. return 0;
  15. }
  16. int disp_mutex_trylock(struct mutex *m)
  17. {
  18. int ret = 0;
  19. ret = mutex_trylock(m);
  20. return ret;
  21. }
  22. int disp_sw_mutex_unlock(struct mutex *m)
  23. {
  24. mutex_unlock(m);
  25. return 0;
  26. }
  27. int disp_msleep(unsigned int ms)
  28. {
  29. msleep(ms);
  30. return 0;
  31. }
  32. long int disp_get_time_us(void)
  33. {
  34. struct timeval t;
  35. do_gettimeofday(&t);
  36. return (t.tv_sec & 0xFFF) * 1000000 + t.tv_usec;
  37. }
  38. unsigned int disp_allocate_mva(unsigned int pa, unsigned int size, M4U_PORT_ID port)
  39. {
  40. int ret = 0;
  41. unsigned int mva = 0;
  42. m4u_client_t *client = NULL;
  43. struct sg_table *sg_table = kzalloc(sizeof(struct sg_table), GFP_ATOMIC);
  44. sg_alloc_table(sg_table, 1, GFP_KERNEL);
  45. sg_dma_address(sg_table->sgl) = pa;
  46. sg_dma_len(sg_table->sgl) = size;
  47. client = m4u_create_client();
  48. if (IS_ERR_OR_NULL(client))
  49. DISPMSG("create client fail!\n");
  50. mva = pa;
  51. ret = m4u_alloc_mva(client, port, 0, sg_table, size, M4U_PROT_READ | M4U_PROT_WRITE,
  52. M4U_FLAGS_FIX_MVA, &mva);
  53. /* m4u_alloc_mva(M4U_PORT_DISP_OVL0, pa_start, (pa_end - pa_start + 1), 0, 0, mva); */
  54. if (ret)
  55. DISPMSG("m4u_alloc_mva returns fail: %d\n", ret);
  56. DISPMSG("[DISPHAL] FB MVA is 0x%08X PA is 0x%08X\n", mva, pa);
  57. return mva;
  58. }