Commit 5a2c485e authored by Michael Hunold's avatar Michael Hunold Committed by Linus Torvalds

[PATCH] dvb: saa7146 driver + misc updates

- saa7146: prefix IER_DISABLE and IER_ENABLE with SAA7146_, add
  SAA7146_ISR_CLEAR

- dvb-bt8xx/dst: fix typo

- cinergyT2: locking in SET_PARAMETERS and some VDR compatibility code for
  GET_EVENT (thanks to Stefan Lucke)
Signed-off-by: default avatarMichael Hunold <hunold@linuxtv.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 019d8b37
...@@ -292,7 +292,7 @@ static irqreturn_t interrupt_hw(int irq, void *dev_id, struct pt_regs *regs) ...@@ -292,7 +292,7 @@ static irqreturn_t interrupt_hw(int irq, void *dev_id, struct pt_regs *regs)
if (0 != (isr & (MASK_16|MASK_17))) { if (0 != (isr & (MASK_16|MASK_17))) {
u32 status = saa7146_read(dev, I2C_STATUS); u32 status = saa7146_read(dev, I2C_STATUS);
if( (0x3 == (status & 0x3)) || (0 == (status & 0x1)) ) { if( (0x3 == (status & 0x3)) || (0 == (status & 0x1)) ) {
IER_DISABLE(dev, MASK_16|MASK_17); SAA7146_IER_DISABLE(dev, MASK_16|MASK_17);
/* only wake up if we expect something */ /* only wake up if we expect something */
if( 0 != dev->i2c_op ) { if( 0 != dev->i2c_op ) {
u32 psr = (saa7146_read(dev, PSR) >> 16) & 0x2; u32 psr = (saa7146_read(dev, PSR) >> 16) & 0x2;
...@@ -311,7 +311,7 @@ static irqreturn_t interrupt_hw(int irq, void *dev_id, struct pt_regs *regs) ...@@ -311,7 +311,7 @@ static irqreturn_t interrupt_hw(int irq, void *dev_id, struct pt_regs *regs)
if( 0 != isr ) { if( 0 != isr ) {
ERR(("warning: interrupt enabled, but not handled properly.(0x%08x)\n",isr)); ERR(("warning: interrupt enabled, but not handled properly.(0x%08x)\n",isr));
ERR(("disabling interrupt source(s)!\n")); ERR(("disabling interrupt source(s)!\n"));
IER_DISABLE(dev,isr); SAA7146_IER_DISABLE(dev,isr);
} }
return IRQ_HANDLED; return IRQ_HANDLED;
} }
......
...@@ -190,7 +190,7 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d ...@@ -190,7 +190,7 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d
saa7146_write(dev, I2C_TRANSFER, *dword); saa7146_write(dev, I2C_TRANSFER, *dword);
dev->i2c_op = 1; dev->i2c_op = 1;
IER_ENABLE(dev, MASK_16|MASK_17); SAA7146_IER_ENABLE(dev, MASK_16|MASK_17);
saa7146_write(dev, MC2, (MASK_00 | MASK_16)); saa7146_write(dev, MC2, (MASK_00 | MASK_16));
wait_event_interruptible(dev->i2c_wq, dev->i2c_op == 0); wait_event_interruptible(dev->i2c_wq, dev->i2c_op == 0);
......
...@@ -91,7 +91,7 @@ static int vbi_workaround(struct saa7146_dev *dev) ...@@ -91,7 +91,7 @@ static int vbi_workaround(struct saa7146_dev *dev)
saa7146_write(dev, MC2, MASK_04|MASK_20); saa7146_write(dev, MC2, MASK_04|MASK_20);
/* enable rps1 irqs */ /* enable rps1 irqs */
IER_ENABLE(dev,MASK_28); SAA7146_IER_ENABLE(dev,MASK_28);
/* prepare to wait to be woken up by the irq-handler */ /* prepare to wait to be woken up by the irq-handler */
add_wait_queue(&vv->vbi_wq, &wait); add_wait_queue(&vv->vbi_wq, &wait);
...@@ -109,7 +109,7 @@ static int vbi_workaround(struct saa7146_dev *dev) ...@@ -109,7 +109,7 @@ static int vbi_workaround(struct saa7146_dev *dev)
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
/* disable rps1 irqs */ /* disable rps1 irqs */
IER_DISABLE(dev,MASK_28); SAA7146_IER_DISABLE(dev,MASK_28);
/* stop video-dma3 */ /* stop video-dma3 */
saa7146_write(dev, MC1, MASK_20); saa7146_write(dev, MC1, MASK_20);
...@@ -190,7 +190,7 @@ static void saa7146_set_vbi_capture(struct saa7146_dev *dev, struct saa7146_buf ...@@ -190,7 +190,7 @@ static void saa7146_set_vbi_capture(struct saa7146_dev *dev, struct saa7146_buf
WRITE_RPS1(CMD_STOP); WRITE_RPS1(CMD_STOP);
/* enable rps1 irqs */ /* enable rps1 irqs */
IER_ENABLE(dev, MASK_28); SAA7146_IER_ENABLE(dev, MASK_28);
/* write the address of the rps-program */ /* write the address of the rps-program */
saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle); saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
...@@ -325,7 +325,7 @@ static void vbi_stop(struct saa7146_fh *fh, struct file *file) ...@@ -325,7 +325,7 @@ static void vbi_stop(struct saa7146_fh *fh, struct file *file)
saa7146_write(dev, MC1, MASK_29); saa7146_write(dev, MC1, MASK_29);
/* disable rps1 irqs */ /* disable rps1 irqs */
IER_DISABLE(dev, MASK_28); SAA7146_IER_DISABLE(dev, MASK_28);
/* shut down dma 3 transfers */ /* shut down dma 3 transfers */
saa7146_write(dev, MC1, MASK_20); saa7146_write(dev, MC1, MASK_20);
......
...@@ -760,7 +760,7 @@ static int video_begin(struct saa7146_fh *fh) ...@@ -760,7 +760,7 @@ static int video_begin(struct saa7146_fh *fh)
saa7146_write(dev, MC2, MASK_27 ); saa7146_write(dev, MC2, MASK_27 );
/* enable rps0 irqs */ /* enable rps0 irqs */
IER_ENABLE(dev, MASK_27); SAA7146_IER_ENABLE(dev, MASK_27);
vv->video_fh = fh; vv->video_fh = fh;
vv->video_status = STATUS_CAPTURE; vv->video_status = STATUS_CAPTURE;
...@@ -805,7 +805,7 @@ static int video_end(struct saa7146_fh *fh, struct file *file) ...@@ -805,7 +805,7 @@ static int video_end(struct saa7146_fh *fh, struct file *file)
saa7146_write(dev, MC1, MASK_28); saa7146_write(dev, MC1, MASK_28);
/* disable rps0 irqs */ /* disable rps0 irqs */
IER_DISABLE(dev, MASK_27); SAA7146_IER_DISABLE(dev, MASK_27);
/* shut down all used video dma transfers */ /* shut down all used video dma transfers */
saa7146_write(dev, MC1, dmas); saa7146_write(dev, MC1, dmas);
......
...@@ -476,10 +476,10 @@ static int dst_type_print(u8 type) ...@@ -476,10 +476,10 @@ static int dst_type_print(u8 type)
otype = "satellite"; otype = "satellite";
break; break;
case DST_TYPE_IS_TERR: case DST_TYPE_IS_TERR:
otype = "terrestial TV"; otype = "terrestrial";
break; break;
case DST_TYPE_IS_CABLE: case DST_TYPE_IS_CABLE:
otype = "terrestial TV"; otype = "cable";
break; break;
default: default:
printk("%s: invalid dst type %d\n", __FUNCTION__, type); printk("%s: invalid dst type %d\n", __FUNCTION__, type);
......
...@@ -139,6 +139,7 @@ struct cinergyt2 { ...@@ -139,6 +139,7 @@ struct cinergyt2 {
struct work_struct query_work; struct work_struct query_work;
wait_queue_head_t poll_wq; wait_queue_head_t poll_wq;
int pending_fe_events;
void *streambuf; void *streambuf;
dma_addr_t streambuf_dmahandle; dma_addr_t streambuf_dmahandle;
...@@ -204,7 +205,7 @@ static const uint32_t rc_keys [] = { ...@@ -204,7 +205,7 @@ static const uint32_t rc_keys [] = {
static int cinergyt2_command (struct cinergyt2 *cinergyt2, static int cinergyt2_command (struct cinergyt2 *cinergyt2,
char *send_buf, int send_buf_len, char *send_buf, int send_buf_len,
char *rec_buf, int rec_buf_len) char *recv_buf, int recv_buf_len)
{ {
int actual_len; int actual_len;
char dummy; char dummy;
...@@ -216,11 +217,11 @@ static int cinergyt2_command (struct cinergyt2 *cinergyt2, ...@@ -216,11 +217,11 @@ static int cinergyt2_command (struct cinergyt2 *cinergyt2,
if (ret) if (ret)
dprintk(1, "usb_bulk_msg (send) failed, err %i\n", ret); dprintk(1, "usb_bulk_msg (send) failed, err %i\n", ret);
if (!rec_buf) if (!recv_buf)
rec_buf = &dummy; recv_buf = &dummy;
ret = usb_bulk_msg(cinergyt2->udev, usb_rcvbulkpipe(cinergyt2->udev, 1), ret = usb_bulk_msg(cinergyt2->udev, usb_rcvbulkpipe(cinergyt2->udev, 1),
rec_buf, rec_buf_len, &actual_len, HZ); recv_buf, recv_buf_len, &actual_len, HZ);
if (ret) if (ret)
dprintk(1, "usb_bulk_msg (read) failed, err %i\n", ret); dprintk(1, "usb_bulk_msg (read) failed, err %i\n", ret);
...@@ -325,7 +326,7 @@ static void cinergyt2_stop_stream_xfer (struct cinergyt2 *cinergyt2) ...@@ -325,7 +326,7 @@ static void cinergyt2_stop_stream_xfer (struct cinergyt2 *cinergyt2)
for (i=0; i<STREAM_URB_COUNT; i++) for (i=0; i<STREAM_URB_COUNT; i++)
if (cinergyt2->stream_urb[i]) if (cinergyt2->stream_urb[i])
usb_unlink_urb(cinergyt2->stream_urb[i]); usb_kill_urb(cinergyt2->stream_urb[i]);
} }
static int cinergyt2_start_stream_xfer (struct cinergyt2 *cinergyt2) static int cinergyt2_start_stream_xfer (struct cinergyt2 *cinergyt2)
...@@ -586,15 +587,24 @@ static int cinergyt2_ioctl (struct inode *inode, struct file *file, ...@@ -586,15 +587,24 @@ static int cinergyt2_ioctl (struct inode *inode, struct file *file,
if (copy_from_user(&p, (void *) arg, sizeof(p))) if (copy_from_user(&p, (void *) arg, sizeof(p)))
return -EFAULT; return -EFAULT;
if (down_interruptible(&cinergyt2->sem))
return -ERESTARTSYS;
param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS; param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
param->tps = cpu_to_le16(compute_tps(&p)); param->tps = cpu_to_le16(compute_tps(&p));
param->freq = cpu_to_le32(p.frequency / 1000); param->freq = cpu_to_le32(p.frequency / 1000);
param->bandwidth = 8 - p.u.ofdm.bandwidth - BANDWIDTH_8_MHZ; param->bandwidth = 8 - p.u.ofdm.bandwidth - BANDWIDTH_8_MHZ;
stat->lock_bits = 0;
cinergyt2->pending_fe_events++;
wake_up_interruptible(&cinergyt2->poll_wq);
err = cinergyt2_command(cinergyt2, err = cinergyt2_command(cinergyt2,
(char *) param, sizeof(*param), (char *) param, sizeof(*param),
NULL, 0); NULL, 0);
up(&cinergyt2->sem);
return (err < 0) ? err : 0; return (err < 0) ? err : 0;
} }
...@@ -608,6 +618,24 @@ static int cinergyt2_ioctl (struct inode *inode, struct file *file, ...@@ -608,6 +618,24 @@ static int cinergyt2_ioctl (struct inode *inode, struct file *file,
*/ */
break; break;
case FE_GET_EVENT:
{
/**
* for now we only fill the status field. the parameters
* are trivial to fill as soon FE_GET_FRONTEND is done.
*/
struct dvb_frontend_event *e = (void *) arg;
if (cinergyt2->pending_fe_events == 0) {
if (file->f_flags & O_NONBLOCK)
return -EWOULDBLOCK;
wait_event_interruptible(cinergyt2->poll_wq,
cinergyt2->pending_fe_events > 0);
}
cinergyt2->pending_fe_events = 0;
return cinergyt2_ioctl(inode, file, FE_READ_STATUS,
(unsigned long) &e->status);
}
default: default:
; ;
} }
...@@ -734,8 +762,10 @@ static void cinergyt2_query (void *data) ...@@ -734,8 +762,10 @@ static void cinergyt2_query (void *data)
unc += le32_to_cpu(s->uncorrected_block_count); unc += le32_to_cpu(s->uncorrected_block_count);
s->uncorrected_block_count = unc; s->uncorrected_block_count = unc;
if (lock_bits != s->lock_bits) if (lock_bits != s->lock_bits) {
wake_up_interruptible(&cinergyt2->poll_wq); wake_up_interruptible(&cinergyt2->poll_wq);
cinergyt2->pending_fe_events++;
}
schedule_delayed_work(&cinergyt2->query_work, schedule_delayed_work(&cinergyt2->query_work,
msecs_to_jiffies(QUERY_INTERVAL)); msecs_to_jiffies(QUERY_INTERVAL));
...@@ -762,6 +792,7 @@ static int cinergyt2_probe (struct usb_interface *intf, ...@@ -762,6 +792,7 @@ static int cinergyt2_probe (struct usb_interface *intf,
INIT_WORK(&cinergyt2->query_work, cinergyt2_query, cinergyt2); INIT_WORK(&cinergyt2->query_work, cinergyt2_query, cinergyt2);
cinergyt2->udev = interface_to_usbdev(intf); cinergyt2->udev = interface_to_usbdev(intf);
cinergyt2->param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
if (cinergyt2_alloc_stream_urbs (cinergyt2) < 0) { if (cinergyt2_alloc_stream_urbs (cinergyt2) < 0) {
dprintk(1, "unable to allocate stream urbs\n"); dprintk(1, "unable to allocate stream urbs\n");
......
...@@ -51,10 +51,12 @@ extern unsigned int saa7146_debug; ...@@ -51,10 +51,12 @@ extern unsigned int saa7146_debug;
#define DEB_INT(x) if (0!=(DEBUG_VARIABLE&0x20)) { DEBUG_PROLOG; printk x; } /* interrupt debug messages */ #define DEB_INT(x) if (0!=(DEBUG_VARIABLE&0x20)) { DEBUG_PROLOG; printk x; } /* interrupt debug messages */
#define DEB_CAP(x) if (0!=(DEBUG_VARIABLE&0x40)) { DEBUG_PROLOG; printk x; } /* capture debug messages */ #define DEB_CAP(x) if (0!=(DEBUG_VARIABLE&0x40)) { DEBUG_PROLOG; printk x; } /* capture debug messages */
#define IER_DISABLE(x,y) \ #define SAA7146_IER_DISABLE(x,y) \
saa7146_write(x, IER, saa7146_read(x, IER) & ~(y)); saa7146_write(x, IER, saa7146_read(x, IER) & ~(y));
#define IER_ENABLE(x,y) \ #define SAA7146_IER_ENABLE(x,y) \
saa7146_write(x, IER, saa7146_read(x, IER) | (y)); saa7146_write(x, IER, saa7146_read(x, IER) | (y));
#define SAA7146_ISR_CLEAR(x,y) \
saa7146_write(x, ISR, (y));
struct saa7146_dev; struct saa7146_dev;
struct saa7146_extension; struct saa7146_extension;
......
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