X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fmedia%2Fvideo%2Farv.c;h=4861799eb4308ce7a6384766caf22263eb17a8f3;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=994b75fe165ab8d63f5a1f7ff036a58d8a9c14e5;hpb=76828883507a47dae78837ab5dec5a5b4513c667;p=linux-2.6.git diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c index 994b75fe1..4861799eb 100644 --- a/drivers/media/video/arv.c +++ b/drivers/media/video/arv.c @@ -18,9 +18,7 @@ * 2003-09-01: Support w3cam by Takeo Takahashi */ -#include #include -#include #include #include #include @@ -31,8 +29,9 @@ #include #include #include +#include +#include -#include #include #include #include @@ -117,7 +116,7 @@ struct ar_device { int width, height; int frame_bytes, line_bytes; wait_queue_head_t wait; - struct semaphore lock; + struct mutex lock; }; static int video_nr = -1; /* video device number (first free) */ @@ -161,39 +160,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(); @@ -204,24 +203,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 */ } /************************************************************************** @@ -253,7 +252,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) @@ -288,7 +287,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; - down(&ar->lock); + mutex_lock(&ar->lock); #if USE_INT local_irq_save(flags); @@ -392,7 +391,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: - up(&ar->lock); + mutex_unlock(&ar->lock); return ret; } @@ -456,7 +455,7 @@ static int ar_do_ioctl(struct inode *inode, struct file *file, (w->width != AR_WIDTH_QVGA || w->height != AR_HEIGHT_QVGA)) return -EINVAL; - down(&ar->lock); + mutex_lock(&ar->lock); ar->width = w->width; ar->height = w->height; if (ar->width == AR_WIDTH_VGA) { @@ -473,7 +472,7 @@ static int ar_do_ioctl(struct inode *inode, struct file *file, ar->line_bytes = AR_LINE_BYTES_QVGA; ar->mode = AR_MODE_INTERLACE; } - up(&ar->lock); + mutex_unlock(&ar->lock); return 0; } case VIDIOCGFBUF: @@ -550,7 +549,7 @@ static int ar_ioctl(struct inode *inode, struct file *file, unsigned int cmd, /* * Interrupt handler */ -static void ar_interrupt(int irq, void *dev, struct pt_regs *regs) +static void ar_interrupt(int irq, void *dev) { struct ar_device *ar = dev; unsigned int line_count; @@ -562,8 +561,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; @@ -651,7 +650,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. */ @@ -734,7 +733,7 @@ static int ar_initialize(struct video_device *dev) void ar_release(struct video_device *vfd) { struct ar_device *ar = vfd->priv; - down(&ar->lock); + mutex_lock(&ar->lock); video_device_release(vfd); } @@ -824,7 +823,7 @@ static int __init ar_init(void) ar->line_bytes = AR_LINE_BYTES_QVGA; ar->mode = AR_MODE_INTERLACE; } - init_MUTEX(&ar->lock); + mutex_init(&ar->lock); init_waitqueue_head(&ar->wait); #if USE_INT @@ -846,7 +845,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");