X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fmedia%2Fvideo%2Farv.c;h=994b75fe165ab8d63f5a1f7ff036a58d8a9c14e5;hb=987b0145d94eecf292d8b301228356f44611ab7c;hp=5c5e682a30042f0528348219fbd3c4ad754a24f6;hpb=3944158a6d33f94668dbd6bdc32ff5c67bb53ec2;p=linux-2.6.git diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c index 5c5e682a3..994b75fe1 100644 --- a/drivers/media/video/arv.c +++ b/drivers/media/video/arv.c @@ -18,7 +18,9 @@ * 2003-09-01: Support w3cam by Takeo Takahashi */ +#include #include +#include #include #include #include @@ -29,9 +31,8 @@ #include #include #include -#include -#include +#include #include #include #include @@ -116,7 +117,7 @@ struct ar_device { int width, height; int frame_bytes, line_bytes; wait_queue_head_t wait; - struct mutex lock; + struct semaphore lock; }; static int video_nr = -1; /* video device number (first free) */ @@ -160,39 +161,39 @@ void iic(int n, unsigned long addr, unsigned long data1, unsigned long data2, { int i; - /* Slave Address */ - ar_outl(addr, PLDI2CDATA); + /* Slave Address */ + ar_outl(addr, PLDI2CDATA); wait_for_vsync(); - /* Start */ - ar_outl(1, PLDI2CCND); + /* Start */ + ar_outl(1, PLDI2CCND); wait_acknowledge(); /* Transfer data 1 */ - ar_outl(data1, PLDI2CDATA); + ar_outl(data1, PLDI2CDATA); wait_for_vsync(); - ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN); + ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN); wait_acknowledge(); /* Transfer data 2 */ - ar_outl(data2, PLDI2CDATA); + ar_outl(data2, PLDI2CDATA); wait_for_vsync(); - ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN); + ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN); wait_acknowledge(); if (n == 3) { /* Transfer data 3 */ - ar_outl(data3, PLDI2CDATA); + ar_outl(data3, PLDI2CDATA); wait_for_vsync(); - ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN); + ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN); wait_acknowledge(); - } + } - /* Stop */ + /* Stop */ for (i = 0; i < 100; i++) cpu_relax(); - ar_outl(2, PLDI2CCND); - ar_outl(2, PLDI2CCND); + ar_outl(2, PLDI2CCND); + ar_outl(2, PLDI2CCND); while (ar_inl(PLDI2CSTS) & PLDI2CSTS_BB) cpu_relax(); @@ -203,24 +204,24 @@ void init_iic(void) { DEBUG(1, "init_iic:\n"); - /* + /* * ICU Setting (iic) */ - /* I2C Setting */ - ar_outl(0x0, PLDI2CCR); /* I2CCR Disable */ - ar_outl(0x0300, PLDI2CMOD); /* I2CMOD ACK/8b-data/7b-addr/auto */ - ar_outl(0x1, PLDI2CACK); /* I2CACK ACK */ + /* I2C Setting */ + ar_outl(0x0, PLDI2CCR); /* I2CCR Disable */ + ar_outl(0x0300, PLDI2CMOD); /* I2CMOD ACK/8b-data/7b-addr/auto */ + ar_outl(0x1, PLDI2CACK); /* I2CACK ACK */ - /* I2C CLK */ - /* 50MH-100k */ + /* I2C CLK */ + /* 50MH-100k */ if (freq == 75) { - ar_outl(369, PLDI2CFREQ); /* BCLK = 75MHz */ + ar_outl(369, PLDI2CFREQ); /* BCLK = 75MHz */ } else if (freq == 50) { ar_outl(244, PLDI2CFREQ); /* BCLK = 50MHz */ } else { ar_outl(244, PLDI2CFREQ); /* default: BCLK = 50MHz */ } - ar_outl(0x1, PLDI2CCR); /* I2CCR Enable */ + ar_outl(0x1, PLDI2CCR); /* I2CCR Enable */ } /************************************************************************** @@ -252,7 +253,7 @@ static inline void wait_for_vertical_sync(int exp_line) /* * check HCOUNT because we cannot check vertical sync. - */ + */ for (; tmout >= 0; tmout--) { l = ar_inl(ARVHCOUNT); if (l == exp_line) @@ -287,7 +288,7 @@ static ssize_t ar_read(struct file *file, char *buf, size_t count, loff_t *ppos) if (ar->mode == AR_MODE_NORMAL) arvcr1 |= ARVCR1_NORMAL; - mutex_lock(&ar->lock); + down(&ar->lock); #if USE_INT local_irq_save(flags); @@ -391,7 +392,7 @@ static ssize_t ar_read(struct file *file, char *buf, size_t count, loff_t *ppos) } DEBUG(1, "ret = %d\n", ret); out_up: - mutex_unlock(&ar->lock); + up(&ar->lock); return ret; } @@ -455,7 +456,7 @@ static int ar_do_ioctl(struct inode *inode, struct file *file, (w->width != AR_WIDTH_QVGA || w->height != AR_HEIGHT_QVGA)) return -EINVAL; - mutex_lock(&ar->lock); + down(&ar->lock); ar->width = w->width; ar->height = w->height; if (ar->width == AR_WIDTH_VGA) { @@ -472,7 +473,7 @@ static int ar_do_ioctl(struct inode *inode, struct file *file, ar->line_bytes = AR_LINE_BYTES_QVGA; ar->mode = AR_MODE_INTERLACE; } - mutex_unlock(&ar->lock); + up(&ar->lock); return 0; } case VIDIOCGFBUF: @@ -561,8 +562,8 @@ static void ar_interrupt(int irq, void *dev, struct pt_regs *regs) /* operations for interlace mode */ if ( line_count < (AR_HEIGHT_VGA/2) ) /* even line */ line_number = (line_count << 1); - else /* odd line */ - line_number = + else /* odd line */ + line_number = (((line_count - (AR_HEIGHT_VGA/2)) << 1) + 1); } else { line_number = line_count; @@ -650,7 +651,7 @@ static int ar_initialize(struct video_device *dev) cr |= ARVCR1_NORMAL; ar_outl(cr, ARVCR1); - /* + /* * Initialize IIC so that CPU can communicate with AR LSI, * and send boot commands to AR LSI. */ @@ -733,7 +734,7 @@ static int ar_initialize(struct video_device *dev) void ar_release(struct video_device *vfd) { struct ar_device *ar = vfd->priv; - mutex_lock(&ar->lock); + down(&ar->lock); video_device_release(vfd); } @@ -823,7 +824,7 @@ static int __init ar_init(void) ar->line_bytes = AR_LINE_BYTES_QVGA; ar->mode = AR_MODE_INTERLACE; } - mutex_init(&ar->lock); + init_MUTEX(&ar->lock); init_waitqueue_head(&ar->wait); #if USE_INT @@ -845,7 +846,7 @@ static int __init ar_init(void) * so register video device as a frame grabber type. * device is named "video[0-64]". * video_register_device() initializes h/w using ar_initialize(). - */ + */ if (video_register_device(ar->vdev, VFL_TYPE_GRABBER, video_nr) != 0) { /* return -1, -ENFILE(full) or others */ printk("arv: register video (Colour AR) failed.\n");