mdp_dma_tv.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* Copyright (c) 2008-2009, 2012 The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. */
  13. #include <linux/module.h>
  14. #include <linux/kernel.h>
  15. #include <linux/sched.h>
  16. #include <linux/time.h>
  17. #include <linux/init.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/hrtimer.h>
  20. #include <linux/delay.h>
  21. #include <mach/hardware.h>
  22. #include <linux/io.h>
  23. #include <asm/system.h>
  24. #include <asm/mach-types.h>
  25. #include <linux/semaphore.h>
  26. #include <linux/spinlock.h>
  27. #include <linux/fb.h>
  28. #include "mdp.h"
  29. #include "msm_fb.h"
  30. extern spinlock_t mdp_spin_lock;
  31. extern uint32 mdp_intr_mask;
  32. int mdp_dma3_on(struct platform_device *pdev)
  33. {
  34. struct msm_fb_data_type *mfd;
  35. struct fb_info *fbi;
  36. uint8 *buf;
  37. int bpp;
  38. int ret = 0;
  39. mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev);
  40. if (!mfd)
  41. return -ENODEV;
  42. if (mfd->key != MFD_KEY)
  43. return -EINVAL;
  44. fbi = mfd->fbi;
  45. /* MDP cmd block enable */
  46. mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE);
  47. bpp = fbi->var.bits_per_pixel / 8;
  48. buf = (uint8 *) fbi->fix.smem_start;
  49. buf += calc_fb_offset(mfd, fbi, bpp);
  50. /* starting address[31..8] of Video frame buffer is CS0 */
  51. MDP_OUTP(MDP_BASE + 0xC0008, (uint32) buf >> 3);
  52. mdp_pipe_ctrl(MDP_DMA3_BLOCK, MDP_BLOCK_POWER_ON, FALSE);
  53. MDP_OUTP(MDP_BASE + 0xC0004, 0x4c60674); /* flicker filter enabled */
  54. MDP_OUTP(MDP_BASE + 0xC0010, 0x20); /* sobel treshold */
  55. MDP_OUTP(MDP_BASE + 0xC0018, 0xeb0010); /* Y Max, Y min */
  56. MDP_OUTP(MDP_BASE + 0xC001C, 0xf00010); /* Cb Max, Cb min */
  57. MDP_OUTP(MDP_BASE + 0xC0020, 0xf00010); /* Cb Max, Cb min */
  58. MDP_OUTP(MDP_BASE + 0xC000C, 0x67686970); /* add a few chars for CC */
  59. MDP_OUTP(MDP_BASE + 0xC0000, 0x1); /* MDP tv out enable */
  60. /* MDP cmd block disable */
  61. mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE);
  62. ret = panel_next_on(pdev);
  63. return ret;
  64. }
  65. int mdp_dma3_off(struct platform_device *pdev)
  66. {
  67. int ret = 0;
  68. ret = panel_next_off(pdev);
  69. if (ret)
  70. return ret;
  71. /* MDP cmd block enable */
  72. mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE);
  73. MDP_OUTP(MDP_BASE + 0xC0000, 0x0);
  74. /* MDP cmd block disable */
  75. mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE);
  76. mdp_pipe_ctrl(MDP_DMA3_BLOCK, MDP_BLOCK_POWER_OFF, FALSE);
  77. /* delay to make sure the last frame finishes */
  78. msleep(16);
  79. return ret;
  80. }
  81. void mdp_dma3_update(struct msm_fb_data_type *mfd)
  82. {
  83. struct fb_info *fbi = mfd->fbi;
  84. uint8 *buf;
  85. int bpp;
  86. unsigned long flag;
  87. if (!mfd->panel_power_on)
  88. return;
  89. /* no need to power on cmd block since dma3 is running */
  90. bpp = fbi->var.bits_per_pixel / 8;
  91. buf = (uint8 *) fbi->fix.smem_start;
  92. buf += calc_fb_offset(mfd, fbi, bpp);
  93. MDP_OUTP(MDP_BASE + 0xC0008, (uint32) buf >> 3);
  94. spin_lock_irqsave(&mdp_spin_lock, flag);
  95. mdp_enable_irq(MDP_DMA3_TERM);
  96. INIT_COMPLETION(mfd->dma->comp);
  97. mfd->dma->waiting = TRUE;
  98. outp32(MDP_INTR_CLEAR, TV_OUT_DMA3_START);
  99. mdp_intr_mask |= TV_OUT_DMA3_START;
  100. outp32(MDP_INTR_ENABLE, mdp_intr_mask);
  101. spin_unlock_irqrestore(&mdp_spin_lock, flag);
  102. wait_for_completion_killable(&mfd->dma->comp);
  103. mdp_disable_irq(MDP_DMA3_TERM);
  104. }