Commit e5514f10 authored by Andy Walls's avatar Andy Walls Committed by Mauro Carvalho Chehab

V4L/DVB: cx23885: Move AV Core irq handling to a work handler

Interrupts from the AV Core are best handled by a workqueue handler
since many I2C transactions are required to service the AV Core
interrupt.  The AV_CORE PCI interrupt is disabled by the IRQ handler
and reenabled when the work handler is finished.
Signed-off-by: default avatarAndy Walls <awalls@md.metrocast.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent dbe83a3b
cx23885-objs := cx23885-cards.o cx23885-video.o cx23885-vbi.o \ cx23885-objs := cx23885-cards.o cx23885-video.o cx23885-vbi.o \
cx23885-core.o cx23885-i2c.o cx23885-dvb.o cx23885-417.o \ cx23885-core.o cx23885-i2c.o cx23885-dvb.o cx23885-417.o \
cx23885-ioctl.o cx23885-ir.o cx23885-input.o cx23888-ir.o \ cx23885-ioctl.o cx23885-ir.o cx23885-av.o cx23885-input.o \
netup-init.o cimax2.o netup-eeprom.o cx23885-f300.o cx23888-ir.o netup-init.o cimax2.o netup-eeprom.o \
cx23885-f300.o
obj-$(CONFIG_VIDEO_CX23885) += cx23885.o obj-$(CONFIG_VIDEO_CX23885) += cx23885.o
......
/*
* Driver for the Conexant CX23885/7/8 PCIe bridge
*
* AV device support routines - non-input, non-vl42_subdev routines
*
* Copyright (C) 2010 Andy Walls <awalls@md.metrocast.net>
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#include "cx23885.h"
void cx23885_av_work_handler(struct work_struct *work)
{
struct cx23885_dev *dev =
container_of(work, struct cx23885_dev, cx25840_work);
bool handled;
v4l2_subdev_call(dev->sd_cx25840, core, interrupt_service_routine,
PCI_MSK_AV_CORE, &handled);
cx23885_irq_enable(dev, PCI_MSK_AV_CORE);
}
/*
* Driver for the Conexant CX23885/7/8 PCIe bridge
*
* AV device support routines - non-input, non-vl42_subdev routines
*
* Copyright (C) 2010 Andy Walls <awalls@md.metrocast.net>
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef _CX23885_AV_H_
#define _CX23885_AV_H_
void cx23885_av_work_handler(struct work_struct *work);
#endif
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "cimax2.h" #include "cimax2.h"
#include "cx23888-ir.h" #include "cx23888-ir.h"
#include "cx23885-ir.h" #include "cx23885-ir.h"
#include "cx23885-av.h"
#include "cx23885-input.h" #include "cx23885-input.h"
MODULE_DESCRIPTION("Driver for cx23885 based TV cards"); MODULE_DESCRIPTION("Driver for cx23885 based TV cards");
...@@ -1856,12 +1857,12 @@ static irqreturn_t cx23885_irq(int irq, void *dev_id) ...@@ -1856,12 +1857,12 @@ static irqreturn_t cx23885_irq(int irq, void *dev_id)
handled++; handled++;
} }
if (pci_status & PCI_MSK_AV_CORE) { if ((pci_status & pci_mask) & PCI_MSK_AV_CORE) {
subdev_handled = false; cx23885_irq_disable(dev, PCI_MSK_AV_CORE);
v4l2_subdev_call(dev->sd_cx25840, if (!schedule_work(&dev->cx25840_work))
core, interrupt_service_routine, printk(KERN_ERR "%s: failed to set up deferred work for"
pci_status, &subdev_handled); " AV Core/IR interrupt. Interrupt is disabled"
if (subdev_handled) " and won't be re-enabled\n", dev->name);
handled++; handled++;
} }
...@@ -1882,11 +1883,11 @@ static void cx23885_v4l2_dev_notify(struct v4l2_subdev *sd, ...@@ -1882,11 +1883,11 @@ static void cx23885_v4l2_dev_notify(struct v4l2_subdev *sd,
dev = to_cx23885(sd->v4l2_dev); dev = to_cx23885(sd->v4l2_dev);
switch (notification) { switch (notification) {
case V4L2_SUBDEV_IR_RX_NOTIFY: /* Called in an IRQ context */ case V4L2_SUBDEV_IR_RX_NOTIFY: /* Possibly called in an IRQ context */
if (sd == dev->sd_ir) if (sd == dev->sd_ir)
cx23885_ir_rx_v4l2_dev_notify(sd, *(u32 *)arg); cx23885_ir_rx_v4l2_dev_notify(sd, *(u32 *)arg);
break; break;
case V4L2_SUBDEV_IR_TX_NOTIFY: /* Called in an IRQ context */ case V4L2_SUBDEV_IR_TX_NOTIFY: /* Possibly called in an IRQ context */
if (sd == dev->sd_ir) if (sd == dev->sd_ir)
cx23885_ir_tx_v4l2_dev_notify(sd, *(u32 *)arg); cx23885_ir_tx_v4l2_dev_notify(sd, *(u32 *)arg);
break; break;
...@@ -1895,6 +1896,7 @@ static void cx23885_v4l2_dev_notify(struct v4l2_subdev *sd, ...@@ -1895,6 +1896,7 @@ static void cx23885_v4l2_dev_notify(struct v4l2_subdev *sd,
static void cx23885_v4l2_dev_notify_init(struct cx23885_dev *dev) static void cx23885_v4l2_dev_notify_init(struct cx23885_dev *dev)
{ {
INIT_WORK(&dev->cx25840_work, cx23885_av_work_handler);
INIT_WORK(&dev->ir_rx_work, cx23885_ir_rx_work_handler); INIT_WORK(&dev->ir_rx_work, cx23885_ir_rx_work_handler);
INIT_WORK(&dev->ir_tx_work, cx23885_ir_tx_work_handler); INIT_WORK(&dev->ir_tx_work, cx23885_ir_tx_work_handler);
dev->v4l2_dev.notify = cx23885_v4l2_dev_notify; dev->v4l2_dev.notify = cx23885_v4l2_dev_notify;
......
...@@ -72,7 +72,7 @@ void cx23885_ir_tx_work_handler(struct work_struct *work) ...@@ -72,7 +72,7 @@ void cx23885_ir_tx_work_handler(struct work_struct *work)
} }
/* Called in an IRQ context */ /* Possibly called in an IRQ context */
void cx23885_ir_rx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events) void cx23885_ir_rx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events)
{ {
struct cx23885_dev *dev = to_cx23885(sd->v4l2_dev); struct cx23885_dev *dev = to_cx23885(sd->v4l2_dev);
...@@ -86,10 +86,18 @@ void cx23885_ir_rx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events) ...@@ -86,10 +86,18 @@ void cx23885_ir_rx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events)
set_bit(CX23885_IR_RX_HW_FIFO_OVERRUN, notifications); set_bit(CX23885_IR_RX_HW_FIFO_OVERRUN, notifications);
if (events & V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN) if (events & V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN)
set_bit(CX23885_IR_RX_SW_FIFO_OVERRUN, notifications); 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); schedule_work(&dev->ir_rx_work);
} }
/* Called in an IRQ context */ /* Possibly called in an IRQ context */
void cx23885_ir_tx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events) void cx23885_ir_tx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events)
{ {
struct cx23885_dev *dev = to_cx23885(sd->v4l2_dev); struct cx23885_dev *dev = to_cx23885(sd->v4l2_dev);
...@@ -97,5 +105,13 @@ void cx23885_ir_tx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events) ...@@ -97,5 +105,13 @@ void cx23885_ir_tx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events)
if (events & V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ) if (events & V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ)
set_bit(CX23885_IR_TX_FIFO_SERVICE_REQ, notifications); 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); schedule_work(&dev->ir_tx_work);
} }
...@@ -366,6 +366,7 @@ struct cx23885_dev { ...@@ -366,6 +366,7 @@ struct cx23885_dev {
unsigned char radio_addr; unsigned char radio_addr;
unsigned int has_radio; unsigned int has_radio;
struct v4l2_subdev *sd_cx25840; struct v4l2_subdev *sd_cx25840;
struct work_struct cx25840_work;
/* Infrared */ /* Infrared */
struct v4l2_subdev *sd_ir; struct v4l2_subdev *sd_ir;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment