cx23885-ir.c 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Driver for the Conexant CX23885/7/8 PCIe bridge
  3. *
  4. * Infrared device support routines - non-input, non-vl42_subdev routines
  5. *
  6. * Copyright (C) 2009 Andy Walls <awalls@radix.net>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  21. * 02110-1301, USA.
  22. */
  23. #include <media/v4l2-device.h>
  24. #include "cx23885.h"
  25. #define CX23885_IR_RX_FIFO_SERVICE_REQ 0
  26. #define CX23885_IR_RX_END_OF_RX_DETECTED 1
  27. #define CX23885_IR_RX_HW_FIFO_OVERRUN 2
  28. #define CX23885_IR_RX_SW_FIFO_OVERRUN 3
  29. #define CX23885_IR_TX_FIFO_SERVICE_REQ 0
  30. void cx23885_ir_rx_work_handler(struct work_struct *work)
  31. {
  32. struct cx23885_dev *dev =
  33. container_of(work, struct cx23885_dev, ir_rx_work);
  34. u32 events = 0;
  35. unsigned long *notifications = &dev->ir_rx_notifications;
  36. if (test_and_clear_bit(CX23885_IR_RX_SW_FIFO_OVERRUN, notifications))
  37. events |= V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN;
  38. if (test_and_clear_bit(CX23885_IR_RX_HW_FIFO_OVERRUN, notifications))
  39. events |= V4L2_SUBDEV_IR_RX_HW_FIFO_OVERRUN;
  40. if (test_and_clear_bit(CX23885_IR_RX_END_OF_RX_DETECTED, notifications))
  41. events |= V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED;
  42. if (test_and_clear_bit(CX23885_IR_RX_FIFO_SERVICE_REQ, notifications))
  43. events |= V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ;
  44. if (events == 0)
  45. return;
  46. }
  47. void cx23885_ir_tx_work_handler(struct work_struct *work)
  48. {
  49. struct cx23885_dev *dev =
  50. container_of(work, struct cx23885_dev, ir_tx_work);
  51. u32 events = 0;
  52. unsigned long *notifications = &dev->ir_tx_notifications;
  53. if (test_and_clear_bit(CX23885_IR_TX_FIFO_SERVICE_REQ, notifications))
  54. events |= V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ;
  55. if (events == 0)
  56. return;
  57. }
  58. /* Called in an IRQ context */
  59. void cx23885_ir_rx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events)
  60. {
  61. struct cx23885_dev *dev = to_cx23885(sd->v4l2_dev);
  62. unsigned long *notifications = &dev->ir_rx_notifications;
  63. if (events & V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ)
  64. set_bit(CX23885_IR_RX_FIFO_SERVICE_REQ, notifications);
  65. if (events & V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED)
  66. set_bit(CX23885_IR_RX_END_OF_RX_DETECTED, notifications);
  67. if (events & V4L2_SUBDEV_IR_RX_HW_FIFO_OVERRUN)
  68. set_bit(CX23885_IR_RX_HW_FIFO_OVERRUN, notifications);
  69. if (events & V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN)
  70. set_bit(CX23885_IR_RX_SW_FIFO_OVERRUN, notifications);
  71. schedule_work(&dev->ir_rx_work);
  72. }
  73. /* Called in an IRQ context */
  74. void cx23885_ir_tx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events)
  75. {
  76. struct cx23885_dev *dev = to_cx23885(sd->v4l2_dev);
  77. unsigned long *notifications = &dev->ir_tx_notifications;
  78. if (events & V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ)
  79. set_bit(CX23885_IR_TX_FIFO_SERVICE_REQ, notifications);
  80. schedule_work(&dev->ir_tx_work);
  81. }