Commit c634920a authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/v4l-dvb

* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/v4l-dvb: (310 commits)
  V4L/DVB (6316): Change list_for_each+list_entry to list_for_each_entry
  V4L/DVB (6315): pvrusb2: Change list_for_each+list_entry to list_for_each_entry
  V4L/DVB (6314): saa7134: Replace list_for_each+list_entry with list_for_each_entry
  V4L/DVB (6313): ivtv: Replace list_for_each+list_entry with list_for_each_entry
  V4L/DVB (6312): cx88: Replace list_for_each+list_entry with list_for_each_entry
  V4L/DVB (6311): dvb: Replace list_for_each+list_entry with list_for_each_entry
  V4L/DVB (6308): V4L: zc0301, remove bad usage of ERESTARTSYS
  V4L/DVB (6307): V4L: w9968cf, remove bad usage of ERESTARTSYS
  V4L/DVB (6306): Few clenups for saa7134 resume code
  V4L/DVB (6305): V4L: videobuf-core.c avoid NULL dereferences in videobuf-core
  V4L/DVB (6301): pvrusb: Update DEBUGIFC sysfs to kernel 2.6.13+
  V4L/DVB (6300): CodingStyle cleanup
  V4L/DVB (6299): dvb: Add dependencies for VIDEOBUF_DVB
  V4L/DVB (6297): cx23885: remove wrong Kconfig selection of VIDEOBUF
  V4L/DVB (6296): dib0700: add support for AverMedia DVB-T Express card
  V4L/DVB (6295): saa7134: add autodetection for KWorld ATSC-115
  V4L/DVB (6293): V4L: convert struct class_device to struct device
  V4L/DVB (6292): videobuf_core init always require callback implementation
  V4L/DVB (6291): Fix: avoid oops on some SMP machines
  V4L/DVB (6290): remove videobuf_set_pci_ops
  ...
parents 6abd2c86 a991f44b
......@@ -150,7 +150,7 @@ Some very frequently asked questions about linuxtv-dvb
- saa7146_vv: SAA7146 video and vbi functions. These are only needed
for full-featured cards.
- video-buf: capture helper module for the saa7146_vv driver. This
- videobuf-dma-sg: capture helper module for the saa7146_vv driver. This
one is responsible to handle capture buffers.
- dvb-ttpci: The main driver for AV7110 based, full-featured
......
......@@ -147,3 +147,4 @@
146 -> SSAI Ultrasound Video Interface [414a:5353]
147 -> VoodooTV 200 (USA) [121a:3000]
148 -> DViCO FusionHDTV 2 [dbc0:d200]
149 -> Typhoon TV-Tuner PCI (50684)
0 -> UNKNOWN/GENERIC [0070:3400]
1 -> Hauppauge WinTV-HVR1800lp [0070:7600]
2 -> Hauppauge WinTV-HVR1800 [0070:7800,0070:7801]
3 -> Hauppauge WinTV-HVR1250 [0070:7911]
4 -> DViCO FusionHDTV5 Express [18ac:d500]
......@@ -88,11 +88,11 @@
87 -> ADS Instant TV Duo Cardbus PTV331 [0331:1421]
88 -> Tevion/KWorld DVB-T 220RF [17de:7201]
89 -> ELSA EX-VISION 700TV [1048:226c]
90 -> Kworld ATSC110 [17de:7350]
90 -> Kworld ATSC110/115 [17de:7350,17de:7352]
91 -> AVerMedia A169 B [1461:7360]
92 -> AVerMedia A169 B1 [1461:6360]
93 -> Medion 7134 Bridge #2 [16be:0005]
94 -> LifeView FlyDVB-T Hybrid Cardbus [5168:3306,5168:3502]
94 -> LifeView FlyDVB-T Hybrid Cardbus/MSI TV @nywhere A/D NB [5168:3306,5168:3502,4e42:3502]
95 -> LifeView FlyVIDEO3000 (NTSC) [5169:0138]
96 -> Medion Md8800 Quadro [16be:0007,16be:0008]
97 -> LifeView FlyDVB-S /Acorp TV134DS [5168:0300,4e42:0300]
......@@ -115,3 +115,4 @@
114 -> KWorld DVB-T 210 [17de:7250]
115 -> Sabrent PCMCIA TV-PCB05 [0919:2003]
116 -> 10MOONS TM300 TV Card [1131:2304]
117 -> Avermedia Super 007 [1461:f01d]
......@@ -69,13 +69,79 @@ source "drivers/media/common/Kconfig"
config VIDEO_TUNER
tristate
depends on I2C
select TUNER_MT20XX if !VIDEO_TUNER_CUSTOMIZE
select TUNER_TDA8290 if !VIDEO_TUNER_CUSTOMIZE
select TUNER_TEA5761 if !VIDEO_TUNER_CUSTOMIZE
select TUNER_TEA5767 if !VIDEO_TUNER_CUSTOMIZE
select TUNER_SIMPLE if !VIDEO_TUNER_CUSTOMIZE
menuconfig VIDEO_TUNER_CUSTOMIZE
bool "Customize analog tuner modules to build"
depends on VIDEO_TUNER
help
This allows the user to deselect tuner drivers unnecessary
for their hardware from the build. Use this option with care
as deselecting tuner drivers which are in fact necessary will
result in V4L devices which cannot be tuned due to lack of
driver support
If unsure say N.
if VIDEO_TUNER_CUSTOMIZE
config TUNER_MT20XX
tristate "Microtune 2032 / 2050 tuners"
depends on I2C
default m if VIDEO_TUNER_CUSTOMIZE
help
Say Y here to include support for the MT2032 / MT2050 tuner.
config TUNER_TDA8290
tristate "TDA 8290+8275(a) tuner combo"
depends on I2C
default m if VIDEO_TUNER_CUSTOMIZE
help
Say Y here to include support for Philips TDA8290+8275(a) tuner.
config TUNER_TEA5761
tristate "TEA 5761 radio tuner (EXPERIMENTAL)"
depends on I2C && EXPERIMENTAL
default m if VIDEO_TUNER_CUSTOMIZE
help
Say Y here to include support for the Philips TEA5761 radio tuner.
config TUNER_TEA5767
tristate "TEA 5767 radio tuner"
depends on I2C
default m if VIDEO_TUNER_CUSTOMIZE
help
Say Y here to include support for the Philips TEA5767 radio tuner.
config TUNER_SIMPLE
tristate "Simple tuner support"
depends on I2C
default m if VIDEO_TUNER_CUSTOMIZE
help
Say Y here to include support for various simple tuners.
config VIDEO_BUF
endif # VIDEO_TUNER_CUSTOMIZE
config VIDEOBUF_GEN
tristate
config VIDEOBUF_DMA_SG
depends on PCI
select VIDEOBUF_GEN
tristate
config VIDEOBUF_VMALLOC
select VIDEOBUF_GEN
tristate
config VIDEO_BUF_DVB
config VIDEOBUF_DVB
tristate
select VIDEOBUF_GEN
select VIDEOBUF_DMA_SG
config VIDEO_BTCX
tristate
......
......@@ -5,5 +5,5 @@ config VIDEO_SAA7146
config VIDEO_SAA7146_VV
tristate
depends on VIDEO_DEV
select VIDEO_BUF
select VIDEOBUF_DMA_SG
select VIDEO_SAA7146
......@@ -21,7 +21,6 @@
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/string.h>
#include <linux/jiffies.h>
#include <media/ir-common.h>
......
......@@ -20,7 +20,6 @@
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/input.h>
#include <media/ir-common.h>
......@@ -1783,3 +1782,64 @@ IR_KEYTAB_TYPE ir_codes_tt_1500[IR_KEYTAB_SIZE] = {
};
EXPORT_SYMBOL_GPL(ir_codes_tt_1500);
/* DViCO FUSION HDTV MCE remote */
IR_KEYTAB_TYPE ir_codes_fusionhdtv_mce[IR_KEYTAB_SIZE] = {
[ 0x0b ] = KEY_1,
[ 0x17 ] = KEY_2,
[ 0x1b ] = KEY_3,
[ 0x07 ] = KEY_4,
[ 0x50 ] = KEY_5,
[ 0x54 ] = KEY_6,
[ 0x48 ] = KEY_7,
[ 0x4c ] = KEY_8,
[ 0x58 ] = KEY_9,
[ 0x03 ] = KEY_0,
[ 0x5e ] = KEY_OK,
[ 0x51 ] = KEY_UP,
[ 0x53 ] = KEY_DOWN,
[ 0x5b ] = KEY_LEFT,
[ 0x5f ] = KEY_RIGHT,
[ 0x02 ] = KEY_TV, /* Labeled DTV on remote */
[ 0x0e ] = KEY_MP3,
[ 0x1a ] = KEY_DVD,
[ 0x1e ] = KEY_FAVORITES, /* Labeled CPF on remote */
[ 0x16 ] = KEY_SETUP,
[ 0x46 ] = KEY_POWER2, /* TV On/Off button on remote */
[ 0x0a ] = KEY_EPG, /* Labeled Guide on remote */
[ 0x49 ] = KEY_BACK,
[ 0x59 ] = KEY_INFO, /* Labeled MORE on remote */
[ 0x4d ] = KEY_MENU, /* Labeled DVDMENU on remote */
[ 0x55 ] = KEY_CYCLEWINDOWS, /* Labeled ALT-TAB on remote */
[ 0x0f ] = KEY_PREVIOUSSONG, /* Labeled |<< REPLAY on remote */
[ 0x12 ] = KEY_NEXTSONG, /* Labeled >>| SKIP on remote */
[ 0x42 ] = KEY_ENTER, /* Labeled START with a green
* MS windows logo on remote */
[ 0x15 ] = KEY_VOLUMEUP,
[ 0x05 ] = KEY_VOLUMEDOWN,
[ 0x11 ] = KEY_CHANNELUP,
[ 0x09 ] = KEY_CHANNELDOWN,
[ 0x52 ] = KEY_CAMERA,
[ 0x5a ] = KEY_TUNER,
[ 0x19 ] = KEY_OPEN,
[ 0x13 ] = KEY_MODE, /* 4:3 16:9 select */
[ 0x1f ] = KEY_ZOOM,
[ 0x43 ] = KEY_REWIND,
[ 0x47 ] = KEY_PLAYPAUSE,
[ 0x4f ] = KEY_FASTFORWARD,
[ 0x57 ] = KEY_MUTE,
[ 0x0d ] = KEY_STOP,
[ 0x01 ] = KEY_RECORD,
[ 0x4e ] = KEY_POWER,
};
EXPORT_SYMBOL_GPL(ir_codes_fusionhdtv_mce);
......@@ -100,7 +100,7 @@ int saa7146_wait_for_debi_done(struct saa7146_dev *dev, int nobusyloop)
* general helper functions
****************************************************************************/
/* this is videobuf_vmalloc_to_sg() from video-buf.c
/* this is videobuf_vmalloc_to_sg() from videobuf-dma-sg.c
make sure virt has been allocated with vmalloc_32(), otherwise the BUG()
may be triggered on highmem machines */
static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages)
......@@ -248,10 +248,11 @@ int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt
static irqreturn_t interrupt_hw(int irq, void *dev_id)
{
struct saa7146_dev *dev = dev_id;
u32 isr = 0;
u32 isr;
u32 ack_isr;
/* read out the interrupt status register */
isr = saa7146_read(dev, ISR);
ack_isr = isr = saa7146_read(dev, ISR);
/* is this our interrupt? */
if ( 0 == isr ) {
......@@ -259,8 +260,6 @@ static irqreturn_t interrupt_hw(int irq, void *dev_id)
return IRQ_NONE;
}
saa7146_write(dev, ISR, isr);
if( 0 != (dev->ext)) {
if( 0 != (dev->ext->irq_mask & isr )) {
if( 0 != dev->ext->irq_func ) {
......@@ -283,21 +282,16 @@ static irqreturn_t interrupt_hw(int irq, void *dev_id)
isr &= ~MASK_28;
}
if (0 != (isr & (MASK_16|MASK_17))) {
u32 status = saa7146_read(dev, I2C_STATUS);
if( (0x3 == (status & 0x3)) || (0 == (status & 0x1)) ) {
SAA7146_IER_DISABLE(dev, MASK_16|MASK_17);
/* only wake up if we expect something */
if( 0 != dev->i2c_op ) {
u32 psr = (saa7146_read(dev, PSR) >> 16) & 0x2;
u32 ssr = (saa7146_read(dev, SSR) >> 17) & 0x1f;
DEB_I2C(("irq: i2c, status: 0x%08x, psr:0x%02x, ssr:0x%02x).\n",status,psr,ssr));
dev->i2c_op = 0;
wake_up(&dev->i2c_wq);
} else {
DEB_I2C(("unexpected irq: i2c, status: 0x%08x, isr %#x\n",status, isr));
}
SAA7146_IER_DISABLE(dev, MASK_16|MASK_17);
/* only wake up if we expect something */
if (0 != dev->i2c_op) {
dev->i2c_op = 0;
wake_up(&dev->i2c_wq);
} else {
DEB_I2C(("unhandled irq: i2c, status: 0x%08x, isr %#x\n",status, isr));
u32 psr = saa7146_read(dev, PSR);
u32 ssr = saa7146_read(dev, SSR);
printk(KERN_WARNING "%s: unexpected i2c irq: isr %08x psr %08x ssr %08x\n",
dev->name, isr, psr, ssr);
}
isr &= ~(MASK_16|MASK_17);
}
......@@ -306,6 +300,7 @@ static irqreturn_t interrupt_hw(int irq, void *dev_id)
ERR(("disabling interrupt source(s)!\n"));
SAA7146_IER_DISABLE(dev,isr);
}
saa7146_write(dev, ISR, ack_isr);
return IRQ_HANDLED;
}
......@@ -548,7 +543,6 @@ EXPORT_SYMBOL_GPL(saa7146_wait_for_debi_done);
EXPORT_SYMBOL_GPL(saa7146_setgpio);
EXPORT_SYMBOL_GPL(saa7146_i2c_transfer);
EXPORT_SYMBOL_GPL(saa7146_i2c_adapter_prepare);
EXPORT_SYMBOL_GPL(saa7146_debug);
......
......@@ -53,13 +53,14 @@ void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits)
void saa7146_dma_free(struct saa7146_dev *dev,struct videobuf_queue *q,
struct saa7146_buf *buf)
{
struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
DEB_EE(("dev:%p, buf:%p\n",dev,buf));
BUG_ON(in_interrupt());
videobuf_waiton(&buf->vb,0,0);
videobuf_dma_unmap(q, &buf->vb.dma);
videobuf_dma_free(&buf->vb.dma);
videobuf_dma_unmap(q, dma);
videobuf_dma_free(dma);
buf->vb.state = STATE_NEEDS_INIT;
}
......
......@@ -202,7 +202,8 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d
/* a signal arrived */
return -ERESTARTSYS;
printk(KERN_WARNING "saa7146_i2c_writeout: timed out waiting for end of xfer\n");
printk(KERN_WARNING "%s %s [irq]: timed out waiting for end of xfer\n",
dev->name, __FUNCTION__);
return -EIO;
}
status = saa7146_read(dev, I2C_STATUS);
......@@ -219,7 +220,8 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d
break;
}
if (time_after(jiffies,timeout)) {
printk(KERN_WARNING "saa7146_i2c_writeout: timed out waiting for MC2\n");
printk(KERN_WARNING "%s %s: timed out waiting for MC2\n",
dev->name, __FUNCTION__);
return -EIO;
}
}
......@@ -235,7 +237,8 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d
/* this is normal when probing the bus
* (no answer from nonexisistant device...)
*/
DEB_I2C(("saa7146_i2c_writeout: timed out waiting for end of xfer\n"));
printk(KERN_WARNING "%s %s [poll]: timed out waiting for end of xfer\n",
dev->name, __FUNCTION__);
return -EIO;
}
if (++trial < 50 && short_delay)
......@@ -246,8 +249,16 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d
}
/* give a detailed status report */
if ( 0 != (status & SAA7146_I2C_ERR)) {
if ( 0 != (status & (SAA7146_I2C_SPERR | SAA7146_I2C_APERR |
SAA7146_I2C_DTERR | SAA7146_I2C_DRERR |
SAA7146_I2C_AL | SAA7146_I2C_ERR |
SAA7146_I2C_BUSY)) ) {
if ( 0 == (status & SAA7146_I2C_ERR) ||
0 == (status & SAA7146_I2C_BUSY) ) {
/* it may take some time until ERR goes high - ignore */
DEB_I2C(("unexpected i2c status %04x\n", status));
}
if( 0 != (status & SAA7146_I2C_SPERR) ) {
DEB_I2C(("error due to invalid start/stop condition.\n"));
}
......@@ -277,7 +288,7 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d
return 0;
}
int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *msgs, int num, int retries)
static int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *msgs, int num, int retries)
{
int i = 0, count = 0;
u32* buffer = dev->d_i2c.cpu_addr;
......
......@@ -165,7 +165,7 @@ static void saa7146_set_vbi_capture(struct saa7146_dev *dev, struct saa7146_buf
/* we don't wait here for the first field anymore. this is different from the video
capture and might cause that the first buffer is only half filled (with only
one field). but since this is some sort of streaming data, this is not that negative.
but by doing this, we can use the whole engine from video-buf.c... */
but by doing this, we can use the whole engine from videobuf-dma-sg.c... */
/*
WRITE_RPS1(CMD_PAUSE | CMD_OAN | CMD_SIG1 | e_wait);
......@@ -239,6 +239,8 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e
saa7146_dma_free(dev,q,buf);
if (STATE_NEEDS_INIT == buf->vb.state) {
struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
buf->vb.width = llength;
buf->vb.height = lines;
buf->vb.size = size;
......@@ -250,7 +252,8 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e
err = videobuf_iolock(q,&buf->vb, NULL);
if (err)
goto oops;
err = saa7146_pgtable_build_single(dev->pci, &buf->pt[2], buf->vb.dma.sglist, buf->vb.dma.sglen);
err = saa7146_pgtable_build_single(dev->pci, &buf->pt[2],
dma->sglist, dma->sglen);
if (0 != err)
return err;
}
......@@ -404,7 +407,7 @@ static int vbi_open(struct saa7146_dev *dev, struct file *file)
fh->vbi_fmt.start[1] = 312;
fh->vbi_fmt.count[1] = 16;
videobuf_queue_init(&fh->vbi_q, &vbi_qops,
videobuf_queue_pci_init(&fh->vbi_q, &vbi_qops,
dev->pci, &dev->slock,
V4L2_BUF_TYPE_VBI_CAPTURE,
V4L2_FIELD_SEQ_TB, // FIXME: does this really work?
......
......@@ -594,8 +594,9 @@ static int set_control(struct saa7146_fh *fh, struct v4l2_control *c)
static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *buf)
{
struct pci_dev *pci = dev->pci;
struct scatterlist *list = buf->vb.dma.sglist;
int length = buf->vb.dma.sglen;
struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
struct scatterlist *list = dma->sglist;
int length = dma->sglen;
struct saa7146_format *sfmt = format_by_fourcc(dev,buf->fmt->pixelformat);
DEB_EE(("dev:%p, buf:%p, sg_len:%d\n",dev,buf,length));
......@@ -655,7 +656,7 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu
/* if we have a user buffer, the first page may not be
aligned to a page boundary. */
pt1->offset = buf->vb.dma.sglist->offset;
pt1->offset = list->offset;
pt2->offset = pt1->offset+o1;
pt3->offset = pt1->offset+o2;
......@@ -1211,6 +1212,8 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
mutex_unlock(&q->lock);
return err;
}
gbuffers = err;
memset(mbuf,0,sizeof(*mbuf));
mbuf->frames = gbuffers;
mbuf->size = gbuffers * gbufsize;
......@@ -1411,7 +1414,7 @@ static int video_open(struct saa7146_dev *dev, struct file *file)
sfmt = format_by_fourcc(dev,fh->video_fmt.pixelformat);
fh->video_fmt.sizeimage = (fh->video_fmt.width * fh->video_fmt.height * sfmt->depth)/8;
videobuf_queue_init(&fh->video_q, &video_qops,
videobuf_queue_pci_init(&fh->video_q, &video_qops,
dev->pci, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
......
......@@ -28,7 +28,6 @@
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/pci.h>
#include <asm/io.h>
......
......@@ -149,11 +149,10 @@ void bt878_start(struct bt878 *bt, u32 controlreg, u32 op_sync_orin,
void bt878_stop(struct bt878 *bt);
#if defined(__powerpc__) /* big-endian */
extern __inline__ void io_st_le32(volatile unsigned __iomem *addr, unsigned val)
static inline void io_st_le32(volatile unsigned __iomem *addr, unsigned val)
{
__asm__ __volatile__("stwbrx %1,0,%2":"=m"(*addr):"r"(val),
"r"(addr));
__asm__ __volatile__("eieio":::"memory");
st_le32(addr, val);
eieio();
}
#define bmtwrite(dat,adr) io_st_le32((adr),(dat))
......
......@@ -21,7 +21,6 @@
#include <linux/bitops.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/device.h>
......
......@@ -548,19 +548,19 @@ static unsigned int cinergyt2_poll (struct file *file, struct poll_table_struct
{
struct dvb_device *dvbdev = file->private_data;
struct cinergyt2 *cinergyt2 = dvbdev->priv;
unsigned int mask = 0;
unsigned int mask = 0;
if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
return -ERESTARTSYS;
poll_wait(file, &cinergyt2->poll_wq, wait);
if (cinergyt2->pending_fe_events != 0)
if (cinergyt2->pending_fe_events != 0)
mask |= (POLLIN | POLLRDNORM | POLLPRI);
mutex_unlock(&cinergyt2->sem);
return mask;
return mask;
}
......@@ -1008,6 +1008,8 @@ static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state)
cinergyt2_sleep(cinergyt2, 1);
mutex_unlock(&cinergyt2->sem);
mutex_unlock(&cinergyt2->wq_sem);
return 0;
}
......
......@@ -24,7 +24,6 @@
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/poll.h>
#include <linux/ioctl.h>
#include <linux/wait.h>
......
</
......@@ -32,11 +32,11 @@
#include <linux/slab.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/vmalloc.h>
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/sched.h>
#include <linux/kthread.h>
#include "dvb_ca_en50221.h"
#include "dvb_ringbuffer.h"
......@@ -140,13 +140,7 @@ struct dvb_ca_private {
wait_queue_head_t wait_queue;
/* PID of the monitoring thread */
pid_t thread_pid;
/* Wait queue used when shutting thread down */
wait_queue_head_t thread_queue;
/* Flag indicating when thread should exit */
unsigned int exit:1;
struct task_struct *thread;
/* Flag indicating if the CA device is open */
unsigned int open:1;
......@@ -902,27 +896,9 @@ static void dvb_ca_en50221_thread_wakeup(struct dvb_ca_private *ca)
ca->wakeup = 1;
mb();
wake_up_interruptible(&ca->thread_queue);
wake_up_process(ca->thread);
}
/**
* Used by the CA thread to determine if an early wakeup is necessary
*
* @param ca CA instance.
*/
static int dvb_ca_en50221_thread_should_wakeup(struct dvb_ca_private *ca)
{
if (ca->wakeup) {
ca->wakeup = 0;
return 1;
}
if (ca->exit)
return 1;
return 0;
}
/**
* Update the delay used by the thread.
*
......@@ -982,7 +958,6 @@ static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca)
static int dvb_ca_en50221_thread(void *data)
{
struct dvb_ca_private *ca = data;
char name[15];
int slot;
int flags;
int status;
......@@ -991,28 +966,17 @@ static int dvb_ca_en50221_thread(void *data)
dprintk("%s\n", __FUNCTION__);
/* setup kernel thread */
snprintf(name, sizeof(name), "kdvb-ca-%i:%i", ca->dvbdev->adapter->num, ca->dvbdev->id);
lock_kernel();
daemonize(name);
sigfillset(&current->blocked);
unlock_kernel();
/* choose the correct initial delay */
dvb_ca_en50221_thread_update_delay(ca);
/* main loop */
while (!ca->exit) {
while (!kthread_should_stop()) {
/* sleep for a bit */
if (!ca->wakeup) {
flags = wait_event_interruptible_timeout(ca->thread_queue,
dvb_ca_en50221_thread_should_wakeup(ca),
ca->delay);
if ((flags == -ERESTARTSYS) || ca->exit) {
/* got signal or quitting */
break;
}
while (!ca->wakeup) {