0001-cec-hdmi.patch 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. diff -Nur linux-3.14.45.orig/drivers/mxc/hdmi-cec/mxc_hdmi-cec.c linux-3.14.45/drivers/mxc/hdmi-cec/mxc_hdmi-cec.c
  2. --- linux-3.14.45.orig/drivers/mxc/hdmi-cec/mxc_hdmi-cec.c 2015-07-16 01:45:57.033999867 -0500
  3. +++ linux-3.14.45/drivers/mxc/hdmi-cec/mxc_hdmi-cec.c 2015-07-16 01:44:12.826000821 -0500
  4. @@ -67,7 +67,6 @@
  5. u8 msg_len;
  6. int tx_answer;
  7. u16 latest_cec_stat;
  8. - u8 link_status;
  9. spinlock_t irq_lock;
  10. struct delayed_work hdmi_cec_work;
  11. struct mutex lock;
  12. @@ -83,8 +82,6 @@
  13. static LIST_HEAD(head);
  14. -static int hdmi_cec_ready = 0;
  15. -static int hdmi_cec_started;
  16. static int hdmi_cec_major;
  17. static struct class *hdmi_cec_class;
  18. static struct hdmi_cec_priv hdmi_cec_data;
  19. @@ -98,7 +95,6 @@
  20. struct hdmi_cec_priv *hdmi_cec = data;
  21. u16 cec_stat = 0;
  22. unsigned long flags;
  23. - u8 phy_stat0;
  24. irqreturn_t ret = IRQ_HANDLED;
  25. spin_lock_irqsave(&hdmi_cec->irq_lock, flags);
  26. @@ -107,7 +103,6 @@
  27. cec_stat = hdmi_readb(HDMI_IH_CEC_STAT0);
  28. hdmi_writeb(cec_stat, HDMI_IH_CEC_STAT0);
  29. - phy_stat0 = hdmi_readb(HDMI_PHY_STAT0) & 0x02;
  30. if ((cec_stat & (HDMI_IH_CEC_STAT0_ERROR_INIT | \
  31. HDMI_IH_CEC_STAT0_NACK | HDMI_IH_CEC_STAT0_EOM | \
  32. @@ -115,14 +110,7 @@
  33. ret = IRQ_NONE;
  34. cec_stat = 0;
  35. }
  36. - if (hdmi_cec->link_status ^ phy_stat0) {
  37. - /* HPD value changed */
  38. - hdmi_cec->link_status = phy_stat0;
  39. - if (hdmi_cec->link_status)
  40. - cec_stat |= 0x80; /* Connected */
  41. - else
  42. - cec_stat |= 0x100; /* Disconnected */
  43. - }
  44. +
  45. pr_debug("HDMI CEC interrupt received\n");
  46. hdmi_cec->latest_cec_stat = cec_stat ;
  47. @@ -315,7 +303,7 @@
  48. mutex_unlock(&hdmi_cec_data.lock);
  49. return -EACCES;
  50. }
  51. - /* Ensure that there is only one writer who is the only listener of tx_cec_queue */
  52. + /* Ensure that there is only one writer who is the unique listener of tx_cec_queue */
  53. if (hdmi_cec_data.tx_answer != CEC_TX_AVAIL) {
  54. mutex_unlock(&hdmi_cec_data.lock);
  55. return -EBUSY;
  56. @@ -363,9 +351,6 @@
  57. {
  58. u8 val;
  59. - if (!hdmi_cec_ready || hdmi_cec_started)
  60. - return;
  61. -
  62. val = hdmi_readb(HDMI_MC_CLKDIS);
  63. val &= ~HDMI_MC_CLKDIS_CECCLK_DISABLE;
  64. hdmi_writeb(val, HDMI_MC_CLKDIS);
  65. @@ -377,12 +362,7 @@
  66. val = HDMI_IH_CEC_STAT0_WAKEUP | HDMI_IH_CEC_STAT0_ERROR_FOLL | HDMI_IH_CEC_STAT0_ARB_LOST;
  67. hdmi_writeb(val, HDMI_CEC_MASK);
  68. hdmi_writeb(val, HDMI_IH_MUTE_CEC_STAT0);
  69. - hdmi_cec_data.link_status = hdmi_readb(HDMI_PHY_STAT0) & 0x02;
  70. - mutex_lock(&hdmi_cec_data.lock);
  71. hdmi_cec_data.cec_state = true;
  72. - mutex_unlock(&hdmi_cec_data.lock);
  73. -
  74. - hdmi_cec_started = 1;
  75. }
  76. EXPORT_SYMBOL(hdmi_cec_start_device);
  77. @@ -390,9 +370,6 @@
  78. {
  79. u8 val;
  80. - if (!hdmi_cec_ready || !hdmi_cec_started)
  81. - return;
  82. -
  83. hdmi_writeb(0x10, HDMI_CEC_CTRL);
  84. val = HDMI_IH_CEC_STAT0_WAKEUP | HDMI_IH_CEC_STAT0_ERROR_FOLL | HDMI_IH_CEC_STAT0_ERROR_INIT | HDMI_IH_CEC_STAT0_ARB_LOST | \
  85. HDMI_IH_CEC_STAT0_NACK | HDMI_IH_CEC_STAT0_EOM | HDMI_IH_CEC_STAT0_DONE;
  86. @@ -402,11 +379,7 @@
  87. val = hdmi_readb(HDMI_MC_CLKDIS);
  88. val |= HDMI_MC_CLKDIS_CECCLK_DISABLE;
  89. hdmi_writeb(val, HDMI_MC_CLKDIS);
  90. - mutex_lock(&hdmi_cec_data.lock);
  91. hdmi_cec_data.cec_state = false;
  92. - mutex_unlock(&hdmi_cec_data.lock);
  93. -
  94. - hdmi_cec_started = 0;
  95. }
  96. EXPORT_SYMBOL(hdmi_cec_stop_device);
  97. @@ -481,11 +454,18 @@
  98. */
  99. static int hdmi_cec_release(struct inode *inode, struct file *filp)
  100. {
  101. + struct hdmi_cec_event *event, *tmp_event;
  102. mutex_lock(&hdmi_cec_data.lock);
  103. if (open_count) {
  104. open_count = 0;
  105. hdmi_cec_data.cec_state = false;
  106. hdmi_cec_data.Logical_address = 15;
  107. +
  108. + /* Flush eventual events which have not been read by user space */
  109. + list_for_each_entry_safe(event, tmp_event, &head, list) {
  110. + list_del(&event->list);
  111. + vfree(event);
  112. + }
  113. }
  114. mutex_unlock(&hdmi_cec_data.lock);
  115. @@ -580,7 +560,6 @@
  116. INIT_DELAYED_WORK(&hdmi_cec_data.hdmi_cec_work, mxc_hdmi_cec_worker);
  117. dev_info(&pdev->dev, "HDMI CEC initialized\n");
  118. - hdmi_cec_ready = 1;
  119. goto out;
  120. err_out_class: