mhl_application.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*!
  2. * @file MHL_application.c
  3. *
  4. * @brief This file specifies the APIs provided to control MHL
  5. * @note Copyright (c) 2013 S2-Tek Co., LTD.
  6. * All rights reserved.
  7. * 19, Innovation First Road, Hsinchu Science Park, 300 Taiwan
  8. * @author
  9. */
  10. /*******************************************************************************
  11. * Header include
  12. ******************************************************************************/
  13. #include <linux/kernel.h> /* printk */
  14. #include <linux/workqueue.h> /* workqueue */
  15. #include "drv_types.h"
  16. #include "mhl_application.h"
  17. #include "cbus_debug.h"
  18. #include "cbus_app.h"
  19. #include "../hdmi_time.h"
  20. /*******************************************************************************
  21. * Constant
  22. ******************************************************************************/
  23. /*******************************************************************************
  24. * Variable
  25. ******************************************************************************/
  26. /*******************************************************************************
  27. * Global Variables
  28. ******************************************************************************/
  29. //GL_Task_t hMHL_CBUS_MainThread;
  30. static struct work_struct MHL_wq;
  31. static struct timer_list MHL_timer;
  32. static BOOL gfMhlWorkEn = FALSE;
  33. //------------------------------------------------------------------------------
  34. //MHL Application Instance Data
  35. //------------------------------------------------------------------------------
  36. void schedule_MHL_timer(struct timer_list *Timer, unsigned int tt);
  37. //------------------------------------------------------------------------------
  38. // Function: MHL_CBUS_main
  39. // Description: Main entry point for MHL driver module
  40. // Parameters: none
  41. // Returns: none
  42. //------------------------------------------------------------------------------
  43. void MHL_CBUS_main(void* arg)
  44. {
  45. //printk("[MHL] MHL_CBUS_main start................." __DATE__"-" __TIME__ "\n");
  46. CbusAppTask();
  47. return;
  48. }
  49. /*******************************************************************************
  50. * Program
  51. ******************************************************************************/
  52. /*!
  53. * @brief Initial the MHL_CBUS.
  54. *
  55. */
  56. void MHL_CBUS_Initial(void)
  57. {
  58. printk("%s\n", __FUNCTION__);
  59. INIT_WORK(&MHL_wq,(work_func_t) MHL_CBUS_main);
  60. init_timer(&MHL_timer);
  61. //return (eStatus == GL_SUCCESS ? DTV_TRUE : DTV_FALSE);
  62. }
  63. void MHL_Poling_TIMER(void* dummy)
  64. {
  65. if(gfMhlWorkEn)
  66. {
  67. schedule_work(&MHL_wq);
  68. schedule_MHL_timer(&MHL_timer,10); //10ms
  69. }
  70. }
  71. void schedule_MHL_timer(struct timer_list *Timer, unsigned int tt)
  72. {
  73. del_timer(Timer);
  74. Timer->expires = jiffies + (HZ*tt) / 1000; // 1ms per unit
  75. Timer->data = (unsigned int)NULL;
  76. Timer->function = (void (*)(unsigned long))MHL_Poling_TIMER;
  77. add_timer(Timer);
  78. }
  79. void MHL_CBUS_Work_Enable(BOOL fEn)
  80. {
  81. printk("%s %d\n", __FUNCTION__, fEn);
  82. //if(gfMhlWorkEn == fEn) //already started or paused, return
  83. // return;
  84. if(fEn)
  85. {
  86. CbusAppDeviceInit();
  87. gfMhlWorkEn = TRUE;
  88. }
  89. else
  90. gfMhlWorkEn = FALSE;
  91. MHL_Poling_TIMER(NULL); //start or pause MHL work
  92. }