linux/drivers/media/pci/cx23885/cx23885-ir.c
Thomas Gleixner c942fddf87 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157
Based on 3 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version this program is distributed in the
  hope that it will be useful but without any warranty without even
  the implied warranty of merchantability or fitness for a particular
  purpose see the gnu general public license for more details

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version [author] [kishon] [vijay] [abraham]
  [i] [kishon]@[ti] [com] this program is distributed in the hope that
  it will be useful but without any warranty without even the implied
  warranty of merchantability or fitness for a particular purpose see
  the gnu general public license for more details

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version [author] [graeme] [gregory]
  [gg]@[slimlogic] [co] [uk] [author] [kishon] [vijay] [abraham] [i]
  [kishon]@[ti] [com] [based] [on] [twl6030]_[usb] [c] [author] [hema]
  [hk] [hemahk]@[ti] [com] this program is distributed in the hope
  that it will be useful but without any warranty without even the
  implied warranty of merchantability or fitness for a particular
  purpose see the gnu general public license for more details

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 1105 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070033.202006027@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:26:37 -07:00

105 lines
3.2 KiB
C

// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Driver for the Conexant CX23885/7/8 PCIe bridge
*
* Infrared device support routines - non-input, non-vl42_subdev routines
*
* Copyright (C) 2009 Andy Walls <awalls@md.metrocast.net>
*/
#include "cx23885.h"
#include "cx23885-ir.h"
#include "cx23885-input.h"
#include <media/v4l2-device.h>
#define CX23885_IR_RX_FIFO_SERVICE_REQ 0
#define CX23885_IR_RX_END_OF_RX_DETECTED 1
#define CX23885_IR_RX_HW_FIFO_OVERRUN 2
#define CX23885_IR_RX_SW_FIFO_OVERRUN 3
#define CX23885_IR_TX_FIFO_SERVICE_REQ 0
void cx23885_ir_rx_work_handler(struct work_struct *work)
{
struct cx23885_dev *dev =
container_of(work, struct cx23885_dev, ir_rx_work);
u32 events = 0;
unsigned long *notifications = &dev->ir_rx_notifications;
if (test_and_clear_bit(CX23885_IR_RX_SW_FIFO_OVERRUN, notifications))
events |= V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN;
if (test_and_clear_bit(CX23885_IR_RX_HW_FIFO_OVERRUN, notifications))
events |= V4L2_SUBDEV_IR_RX_HW_FIFO_OVERRUN;
if (test_and_clear_bit(CX23885_IR_RX_END_OF_RX_DETECTED, notifications))
events |= V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED;
if (test_and_clear_bit(CX23885_IR_RX_FIFO_SERVICE_REQ, notifications))
events |= V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ;
if (events == 0)
return;
if (dev->kernel_ir)
cx23885_input_rx_work_handler(dev, events);
}
void cx23885_ir_tx_work_handler(struct work_struct *work)
{
struct cx23885_dev *dev =
container_of(work, struct cx23885_dev, ir_tx_work);
u32 events = 0;
unsigned long *notifications = &dev->ir_tx_notifications;
if (test_and_clear_bit(CX23885_IR_TX_FIFO_SERVICE_REQ, notifications))
events |= V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ;
if (events == 0)
return;
}
/* Possibly called in an IRQ context */
void cx23885_ir_rx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events)
{
struct cx23885_dev *dev = to_cx23885(sd->v4l2_dev);
unsigned long *notifications = &dev->ir_rx_notifications;
if (events & V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ)
set_bit(CX23885_IR_RX_FIFO_SERVICE_REQ, notifications);
if (events & V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED)
set_bit(CX23885_IR_RX_END_OF_RX_DETECTED, notifications);
if (events & V4L2_SUBDEV_IR_RX_HW_FIFO_OVERRUN)
set_bit(CX23885_IR_RX_HW_FIFO_OVERRUN, notifications);
if (events & V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN)
set_bit(CX23885_IR_RX_SW_FIFO_OVERRUN, notifications);
/*
* For the integrated AV core, we are already in a workqueue context.
* For the CX23888 integrated IR, we are in an interrupt context.
*/
if (sd == dev->sd_cx25840)
cx23885_ir_rx_work_handler(&dev->ir_rx_work);
else
schedule_work(&dev->ir_rx_work);
}
/* Possibly called in an IRQ context */
void cx23885_ir_tx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events)
{
struct cx23885_dev *dev = to_cx23885(sd->v4l2_dev);
unsigned long *notifications = &dev->ir_tx_notifications;
if (events & V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ)
set_bit(CX23885_IR_TX_FIFO_SERVICE_REQ, notifications);
/*
* For the integrated AV core, we are already in a workqueue context.
* For the CX23888 integrated IR, we are in an interrupt context.
*/
if (sd == dev->sd_cx25840)
cx23885_ir_tx_work_handler(&dev->ir_tx_work);
else
schedule_work(&dev->ir_tx_work);
}