Path: blob/master/drivers/media/video/cx23885/cx23885-ir.c
17900 views
/*1* Driver for the Conexant CX23885/7/8 PCIe bridge2*3* Infrared device support routines - non-input, non-vl42_subdev routines4*5* Copyright (C) 2009 Andy Walls <[email protected]>6*7* This program is free software; you can redistribute it and/or8* modify it under the terms of the GNU General Public License9* as published by the Free Software Foundation; either version 210* of the License, or (at your option) any later version.11*12* This program is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15* GNU General Public License for more details.16*17* You should have received a copy of the GNU General Public License18* along with this program; if not, write to the Free Software19* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA20* 02110-1301, USA.21*/2223#include <media/v4l2-device.h>2425#include "cx23885.h"26#include "cx23885-input.h"2728#define CX23885_IR_RX_FIFO_SERVICE_REQ 029#define CX23885_IR_RX_END_OF_RX_DETECTED 130#define CX23885_IR_RX_HW_FIFO_OVERRUN 231#define CX23885_IR_RX_SW_FIFO_OVERRUN 33233#define CX23885_IR_TX_FIFO_SERVICE_REQ 0343536void cx23885_ir_rx_work_handler(struct work_struct *work)37{38struct cx23885_dev *dev =39container_of(work, struct cx23885_dev, ir_rx_work);40u32 events = 0;41unsigned long *notifications = &dev->ir_rx_notifications;4243if (test_and_clear_bit(CX23885_IR_RX_SW_FIFO_OVERRUN, notifications))44events |= V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN;45if (test_and_clear_bit(CX23885_IR_RX_HW_FIFO_OVERRUN, notifications))46events |= V4L2_SUBDEV_IR_RX_HW_FIFO_OVERRUN;47if (test_and_clear_bit(CX23885_IR_RX_END_OF_RX_DETECTED, notifications))48events |= V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED;49if (test_and_clear_bit(CX23885_IR_RX_FIFO_SERVICE_REQ, notifications))50events |= V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ;5152if (events == 0)53return;5455if (dev->kernel_ir)56cx23885_input_rx_work_handler(dev, events);57}5859void cx23885_ir_tx_work_handler(struct work_struct *work)60{61struct cx23885_dev *dev =62container_of(work, struct cx23885_dev, ir_tx_work);63u32 events = 0;64unsigned long *notifications = &dev->ir_tx_notifications;6566if (test_and_clear_bit(CX23885_IR_TX_FIFO_SERVICE_REQ, notifications))67events |= V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ;6869if (events == 0)70return;7172}7374/* Possibly called in an IRQ context */75void cx23885_ir_rx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events)76{77struct cx23885_dev *dev = to_cx23885(sd->v4l2_dev);78unsigned long *notifications = &dev->ir_rx_notifications;7980if (events & V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ)81set_bit(CX23885_IR_RX_FIFO_SERVICE_REQ, notifications);82if (events & V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED)83set_bit(CX23885_IR_RX_END_OF_RX_DETECTED, notifications);84if (events & V4L2_SUBDEV_IR_RX_HW_FIFO_OVERRUN)85set_bit(CX23885_IR_RX_HW_FIFO_OVERRUN, notifications);86if (events & V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN)87set_bit(CX23885_IR_RX_SW_FIFO_OVERRUN, notifications);8889/*90* For the integrated AV core, we are already in a workqueue context.91* For the CX23888 integrated IR, we are in an interrupt context.92*/93if (sd == dev->sd_cx25840)94cx23885_ir_rx_work_handler(&dev->ir_rx_work);95else96schedule_work(&dev->ir_rx_work);97}9899/* Possibly called in an IRQ context */100void cx23885_ir_tx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events)101{102struct cx23885_dev *dev = to_cx23885(sd->v4l2_dev);103unsigned long *notifications = &dev->ir_tx_notifications;104105if (events & V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ)106set_bit(CX23885_IR_TX_FIFO_SERVICE_REQ, notifications);107108/*109* For the integrated AV core, we are already in a workqueue context.110* For the CX23888 integrated IR, we are in an interrupt context.111*/112if (sd == dev->sd_cx25840)113cx23885_ir_tx_work_handler(&dev->ir_tx_work);114else115schedule_work(&dev->ir_tx_work);116}117118119