* 2003-09-01: Support w3cam by Takeo Takahashi
*/
+#include <linux/config.h>
#include <linux/init.h>
+#include <linux/devfs_fs_kernel.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/mm.h>
#include <linux/sched.h>
#include <linux/videodev.h>
-#include <media/v4l2-common.h>
-#include <linux/mutex.h>
+#include <asm/semaphore.h>
#include <asm/uaccess.h>
#include <asm/m32r.h>
#include <asm/io.h>
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) */
{
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();
{
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 */
}
/**************************************************************************
/*
* check HCOUNT because we cannot check vertical sync.
- */
+ */
for (; tmout >= 0; tmout--) {
l = ar_inl(ARVHCOUNT);
if (l == exp_line)
if (ar->mode == AR_MODE_NORMAL)
arvcr1 |= ARVCR1_NORMAL;
- mutex_lock(&ar->lock);
+ down(&ar->lock);
#if USE_INT
local_irq_save(flags);
}
DEBUG(1, "ret = %d\n", ret);
out_up:
- mutex_unlock(&ar->lock);
+ up(&ar->lock);
return ret;
}
(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) {
ar->line_bytes = AR_LINE_BYTES_QVGA;
ar->mode = AR_MODE_INTERLACE;
}
- mutex_unlock(&ar->lock);
+ up(&ar->lock);
return 0;
}
case VIDIOCGFBUF:
/* 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;
cr |= ARVCR1_NORMAL;
ar_outl(cr, ARVCR1);
- /*
+ /*
* Initialize IIC so that CPU can communicate with AR LSI,
* and send boot commands to AR LSI.
*/
void ar_release(struct video_device *vfd)
{
struct ar_device *ar = vfd->priv;
- mutex_lock(&ar->lock);
+ down(&ar->lock);
video_device_release(vfd);
}
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
* 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");