summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux/drivers/media/dvb/av7110/Makefile2
-rw-r--r--linux/drivers/media/dvb/av7110/saa7146.c2
-rw-r--r--linux/drivers/media/dvb/av7110/saa7146_core.c54
-rw-r--r--linux/drivers/media/dvb/av7110/saa7146_core.h29
4 files changed, 39 insertions, 48 deletions
diff --git a/linux/drivers/media/dvb/av7110/Makefile b/linux/drivers/media/dvb/av7110/Makefile
index e5b0d694d..301a73216 100644
--- a/linux/drivers/media/dvb/av7110/Makefile
+++ b/linux/drivers/media/dvb/av7110/Makefile
@@ -6,5 +6,7 @@ dvb-ttpci-objs := saa7146_core.o saa7146_v4l.o av7110.o av7110_ir.o
obj-$(CONFIG_DVB_AV7110) += dvb-ttpci.o
+EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/
+
include $(TOPDIR)/Rules.make
diff --git a/linux/drivers/media/dvb/av7110/saa7146.c b/linux/drivers/media/dvb/av7110/saa7146.c
index d0ef805dd..a636af50c 100644
--- a/linux/drivers/media/dvb/av7110/saa7146.c
+++ b/linux/drivers/media/dvb/av7110/saa7146.c
@@ -1399,7 +1399,7 @@ int i2c_reset(struct saa7146* saa)
/* if any error is still present, a fatal error has occured ... */
if ( SAA7146_I2C_BBR != (status = i2c_status_check(saa)) ) {
hprintk("saa7146: i2c_reset: fatal error, status:0x%08x\n",status);
- return -1;
+ return -EIO;
}
return 0;
diff --git a/linux/drivers/media/dvb/av7110/saa7146_core.c b/linux/drivers/media/dvb/av7110/saa7146_core.c
index 1eb261e9a..7012473a9 100644
--- a/linux/drivers/media/dvb/av7110/saa7146_core.c
+++ b/linux/drivers/media/dvb/av7110/saa7146_core.c
@@ -33,8 +33,8 @@
#include "saa7146_core.h"
#include "saa7146_v4l.h"
#include "av7110.h"
-#include "../dvb-core/compat.h"
-#include "../dvb-core/dvb_i2c.h"
+#include "compat.h"
+#include "dvb_i2c.h"
/* insmod parameter: here you can specify the number of video-buffers
to be allocated. for simple capturing 2 buffers (double-buffering)
@@ -197,23 +197,23 @@ static
int do_master_xfer (struct dvb_i2c_bus *i2c, struct i2c_msg msgs[], int num)
{
struct saa7146 *a = i2c->data;
- int result, count;
+ int count;
int i = 0;
dprintk(KERN_ERR "saa7146_core.o: master_xfer called, num:%d\n",num);
/* prepare the message(s), get number of u32s to transfer */
count = prepare(msgs, num, a->i2c);
- if ( 0 > count ) {
- hprintk(KERN_ERR "saa7146_core.o: master_xfer: could not prepare i2c-message\n");
+
+ if (count < 0) {
+ hprintk(KERN_ERR "saa7146_core.o: could not prepare i2c-message\n");
return -EIO;
}
/* reset the i2c-device if necessary */
- result = i2c_reset( a );
- if ( 0 > result ) {
- hprintk(KERN_ERR "saa7146_core.o: master_xfer: could not reset i2c-bus\n");
- return result;
+ if (i2c_reset(a) < 0) {
+ hprintk(KERN_ERR "saa7146_core.o: could not reset i2c-bus\n");
+ return -EIO;
}
for(i = 0; i < count; i++) {
@@ -222,31 +222,17 @@ int do_master_xfer (struct dvb_i2c_bus *i2c, struct i2c_msg msgs[], int num)
* we do not start the whole rps1-engine...
*/
- result = i2c_write_out( a, &a->i2c[i],
- SAA7146_I2C_TIMEOUT );
-
- if ( 0 != result) {
- /* if address-error occured, don't retry */
- if ( result == -EREMOTEIO )
- {
- hprintk(KERN_ERR "saa7146_core.o: master_xfer: error in address phase\n");
- return result;
- }
- hprintk(KERN_ERR "saa7146_core.o: master_xfer: error transferring, trying again\n");
- break;
+ /* if address-error occured, don't retry */
+ if (i2c_write_out(a, &a->i2c[i], SAA7146_I2C_TIMEOUT) < 0) {
+ hprintk (KERN_ERR "saa7146_core.o: "
+ "i2c error in address phase\n");
+ return -EREMOTEIO;
}
}
- /* see if an error occured & the last retry failed */
- if (0 != result) {
- hprintk(KERN_ERR "saa7146_core.o: master_xfer: could not transfer i2c-message\n");
- return -EIO;
- }
-
/* if any things had to be read, get the results */
- result = clean_up(msgs, num, a->i2c);
- if ( 0 > result ) {
- hprintk(KERN_ERR "saa7146_core.o: master_xfer: could not cleanup\n");
+ if (clean_up(msgs, num, a->i2c) < 0) {
+ hprintk(KERN_ERR "saa7146_core.o: i2c cleanup failed!\n");
return -EIO;
}
@@ -259,13 +245,19 @@ int do_master_xfer (struct dvb_i2c_bus *i2c, struct i2c_msg msgs[], int num)
static
int master_xfer (struct dvb_i2c_bus *i2c, struct i2c_msg msgs[], int num)
{
+ struct saa7146 *saa = i2c->data;
int retries = SAA7146_I2C_RETRIES;
int ret;
+ if (down_interruptible (&saa->i2c_sem))
+ return -ERESTARTSYS;
+
do {
ret = do_master_xfer (i2c, msgs, num);
} while (ret != num && retries--);
+ up (&saa->i2c_sem);
+
return ret;
}
@@ -855,6 +847,8 @@ int __devinit saa7146_init_one (struct pci_dev *pdev,
list_add_tail (&saa->list_head, &saa7146_list);
+ init_MUTEX(&saa->i2c_sem);
+
return 0;
}
diff --git a/linux/drivers/media/dvb/av7110/saa7146_core.h b/linux/drivers/media/dvb/av7110/saa7146_core.h
index 0cd817412..40d5ab0ff 100644
--- a/linux/drivers/media/dvb/av7110/saa7146_core.h
+++ b/linux/drivers/media/dvb/av7110/saa7146_core.h
@@ -1,17 +1,11 @@
#ifndef __SAA7146_CORE__
#define __SAA7146_CORE__
-#include <asm/io.h> /* definitions of u32 etc. */
-#include "../dvb-core/dvbdev.h"
-
-#if LINUX_VERSION_CODE < 0x020300
-#define DECLARE_MUTEX(foo) struct semaphore foo = MUTEX
-#define DECLARE_MUTEX_LOCKED(foo) struct semaphore foo = MUTEX_LOCKED
-#define WAIT_QUEUE struct wait_queue*
-#define init_waitqueue_head(wq) *(wq) = NULL;
-#else
-#define WAIT_QUEUE wait_queue_head_t
-#endif
+#include <asm/io.h>
+#include <asm/semaphore.h>
+
+#include "dvbdev.h"
+
/* maximum number of capture frames we support */
#define SAA7146_MAX_BUF 5
@@ -37,13 +31,14 @@ struct saa7146 {
char name[32]; /* give it a nice name */
struct list_head list_head;
-
- struct dvb_adapter *dvb_adapter;
- struct dvb_i2c_bus *i2c_bus;
struct pci_dev *device;
int card_type;
- void* data[SAA7146_MAX_EXTENSIONS]; /* data hooks for extensions */
+ struct dvb_adapter *dvb_adapter;
+ struct dvb_i2c_bus *i2c_bus;
+ struct semaphore i2c_sem;
+
+ void* data[SAA7146_MAX_EXTENSIONS]; /* data hooks for extensions */
int (*command) (struct dvb_i2c_bus *i, unsigned int cmd, void *arg);
@@ -70,8 +65,8 @@ struct saa7146 {
int grab_format[SAA7146_MAX_BUF]; /* video format of grabs */
int grab_port[SAA7146_MAX_BUF]; /* video port for grab */
- WAIT_QUEUE rps0_wq; /* rps0 interrupt queue (=> capture) */
- WAIT_QUEUE rps1_wq; /* rps1 interrupt queue (=> i2c, ...) */
+ wait_queue_head_t rps0_wq; /* rps0 interrupt queue (=> capture) */
+ wait_queue_head_t rps1_wq; /* rps1 interrupt queue (=> i2c, ...) */
};
#define SAA7146_IRQ_RPS0