Commit 1d61aac0 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB: bw-qcam: coding style cleanup



Clean up the coding style before we convert this driver to V4L2.

Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 51224aa4
Loading
Loading
Loading
Loading
+207 −245
Original line number Diff line number Diff line
@@ -176,8 +176,7 @@ static struct qcam_device *qcam_init(struct parport *port)
	q->pport = port;
	q->pdev = parport_register_device(port, "bw-qcam", NULL, NULL,
			NULL, 0, NULL);
	if (q->pdev == NULL)
	{
	if (q->pdev == NULL) {
		printk(KERN_ERR "bw-qcam: couldn't register for %s.\n",
				port->name);
		kfree(q);
@@ -249,10 +248,8 @@ static int qc_waithand(struct qcam_device *q, int val)
	int status;
	int runs = 0;

	if (val)
	{
		while (!((status = read_lpstatus(q)) & 8))
		{
	if (val) {
		while (!((status = read_lpstatus(q)) & 8)) {
			/* 1000 is enough spins on the I/O for all normal
			   cases, at that point we start to poll slowly
			   until the camera wakes up. However, we are
@@ -261,17 +258,12 @@ static int qc_waithand(struct qcam_device *q, int val)
			   response. */

			if (runs++ > maxpoll)
			{
				msleep_interruptible(5);
			}
			if (runs > (maxpoll + 1000)) /* 5 seconds */
				return -1;
		}
	}
	else
	{
		while (((status = read_lpstatus(q)) & 8))
		{
	} else {
		while (((status = read_lpstatus(q)) & 8)) {
			/* 1000 is enough spins on the I/O for all normal
			   cases, at that point we start to poll slowly
			   until the camera wakes up. However, we are
@@ -280,9 +272,7 @@ static int qc_waithand(struct qcam_device *q, int val)
			   response. */

			if (runs++ > maxpoll)
			{
				msleep_interruptible(5);
			}
			if (runs++ > (maxpoll + 1000)) /* 5 seconds */
				return -1;
		}
@@ -301,8 +291,7 @@ static unsigned int qc_waithand2(struct qcam_device *q, int val)
	unsigned int status;
	int runs = 0;

	do
	{
	do {
		status = read_lpdata(q);
		/* 1000 is enough spins on the I/O for all normal
		   cases, at that point we start to poll slowly
@@ -312,13 +301,10 @@ static unsigned int qc_waithand2(struct qcam_device *q, int val)
		   response. */

		if (runs++ > maxpoll)
		{
			msleep_interruptible(5);
		}
		if (runs++ > (maxpoll + 1000)) /* 5 seconds */
			return 0;
	}
	while ((status & 1) != val);
	} while ((status & 1) != val);

	return status;
}
@@ -342,8 +328,7 @@ static int qc_detect(struct qcam_device *q)

	lastreg = reg = read_lpstatus(q) & 0xf0;

	for (i = 0; i < 500; i++)
	{
	for (i = 0; i < 500; i++) {
		reg = read_lpstatus(q) & 0xf0;
		if (reg != lastreg)
			count++;
@@ -357,7 +342,7 @@ static int qc_detect(struct qcam_device *q)
	   won't be flashing these bits. Possibly unloading the module
	   in the middle of a grab? Or some timeout condition?
	   I've seen this parameter as low as 19 on my 450Mhz box - mpc */
	printk("Debugging: QCam detection counter <30-200 counts as detected>: %d\n", count);
	printk(KERN_DEBUG "Debugging: QCam detection counter <30-200 counts as detected>: %d\n", count);
	return 1;
#endif

@@ -381,8 +366,7 @@ static int qc_detect(struct qcam_device *q)

static void qc_reset(struct qcam_device *q)
{
	switch (q->port_mode & QC_FORCE_MASK)
	{
	switch (q->port_mode & QC_FORCE_MASK) {
	case QC_FORCE_UNIDIR:
		q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR;
		break;
@@ -395,11 +379,10 @@ static void qc_reset(struct qcam_device *q)
		write_lpcontrol(q, 0x20);
		write_lpdata(q, 0x75);

			if (read_lpdata(q) != 0x75) {
		if (read_lpdata(q) != 0x75)
			q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR;
			} else {
		else
			q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR;
			}
		break;
	}

@@ -423,8 +406,7 @@ static int qc_setscanmode(struct qcam_device *q)
{
	int old_mode = q->mode;

	switch (q->transfer_scale)
	{
	switch (q->transfer_scale) {
	case 1:
		q->mode = 0;
		break;
@@ -436,8 +418,7 @@ static int qc_setscanmode(struct qcam_device *q)
		break;
	}

	switch (q->bpp)
	{
	switch (q->bpp) {
	case 4:
		break;
	case 6:
@@ -445,8 +426,7 @@ static int qc_setscanmode(struct qcam_device *q)
		break;
	}

	switch (q->port_mode & QC_MODE_MASK)
	{
	switch (q->port_mode & QC_MODE_MASK) {
	case QC_BIDIR:
		q->mode += 1;
		break;
@@ -526,14 +506,12 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[])
	unsigned int hi2, lo2;
	static int state;

	if (buffer == NULL)
	{
	if (buffer == NULL) {
		state = 0;
		return 0;
	}

	switch (q->port_mode & QC_MODE_MASK)
	{
	switch (q->port_mode & QC_MODE_MASK) {
	case QC_BIDIR:		/* Bi-directional Port */
		write_lpcontrol(q, 0x26);
		lo = (qc_waithand2(q, 1) >> 1);
@@ -541,8 +519,7 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[])
		write_lpcontrol(q, 0x2e);
		lo2 = (qc_waithand2(q, 0) >> 1);
		hi2 = (read_lpstatus(q) >> 3) & 0x1f;
			switch (q->bpp)
			{
		switch (q->bpp) {
		case 4:
			buffer[0] = lo & 0xf;
			buffer[1] = ((lo & 0x70) >> 4) | ((hi & 1) << 3);
@@ -568,16 +545,14 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[])
		write_lpcontrol(q, 0xe);
		hi = (qc_waithand(q, 0) & 0xf0) >> 4;

			switch (q->bpp)
			{
		switch (q->bpp) {
		case 4:
			buffer[0] = lo;
			buffer[1] = hi;
			ret = 2;
			break;
		case 6:
					switch (state)
					{
			switch (state) {
			case 0:
				buffer[0] = (lo << 2) | ((hi & 0xc) >> 2);
				q->saved_bits = (hi & 3) << 4;
@@ -634,13 +609,12 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
	qc_command(q, 0x7);
	qc_command(q, q->mode);

	if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR)
	{
	if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) {
		write_lpcontrol(q, 0x2e);	/* turn port around */
		write_lpcontrol(q, 0x26);
		(void) qc_waithand(q, 1);
		qc_waithand(q, 1);
		write_lpcontrol(q, 0x2e);
		(void) qc_waithand(q, 0);
		qc_waithand(q, 0);
	}

	/* strange -- should be 15:63 below, but 4bpp is odd */
@@ -653,30 +627,25 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
		q->transfer_scale;
	transperline = DIV_ROUND_UP(transperline, divisor);

	for (i = 0, yield = yieldlines; i < linestotrans; i++)
	{
		for (pixels_read = j = 0; j < transperline; j++)
		{
	for (i = 0, yield = yieldlines; i < linestotrans; i++) {
		for (pixels_read = j = 0; j < transperline; j++) {
			bytes = qc_readbytes(q, buffer);
			for (k = 0; k < bytes && (pixels_read + k) < pixels_per_line; k++)
			{
			for (k = 0; k < bytes && (pixels_read + k) < pixels_per_line; k++) {
				int o;
				if (buffer[k] == 0 && invert == 16)
				{
				if (buffer[k] == 0 && invert == 16) {
					/* 4bpp is odd (again) -- inverter is 16, not 15, but output
					   must be 0-15 -- bls */
					buffer[k] = 16;
				}
				o = i * pixels_per_line + pixels_read + k;
				if(o<len)
				{
				if (o < len) {
					got++;
					put_user((invert - buffer[k]) << shift, buf + o);
				}
			}
			pixels_read += bytes;
		}
		(void) qc_readbytes(q, NULL);	/* reset state machine */
		qc_readbytes(q, NULL);	/* reset state machine */

		/* Grabbing an entire frame from the quickcam is a lengthy
		   process. We don't (usually) want to busy-block the
@@ -690,8 +659,7 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
		}
	}

	if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR)
	{
	if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) {
		write_lpcontrol(q, 2);
		write_lpcontrol(q, 6);
		udelay(3);
@@ -711,8 +679,7 @@ static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
	struct video_device *dev = video_devdata(file);
	struct qcam_device *qcam = (struct qcam_device *)dev;

	switch(cmd)
	{
	switch (cmd) {
	case VIDIOCGCAP:
		{
			struct video_capability *b = arg;
@@ -819,11 +786,8 @@ static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
			qcam->transfer_scale = 4;

			if (vw->width >= 160 && vw->height >= 120)
			{
				qcam->transfer_scale = 2;
			}
			if(vw->width>=320 && vw->height>=240)
			{
			if (vw->width >= 320 && vw->height >= 240) {
				qcam->width = 320;
				qcam->height = 240;
				qcam->transfer_scale = 1;
@@ -842,6 +806,7 @@ static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
	case VIDIOCGWIN:
		{
			struct video_window *vw = arg;

			memset(vw, 0, sizeof(*vw));
			vw->width = qcam->width / qcam->transfer_scale;
			vw->height = qcam->height / qcam->transfer_scale;
@@ -917,8 +882,7 @@ static const struct v4l2_file_operations qcam_fops = {
	.ioctl          = qcam_ioctl,
	.read		= qcam_read,
};
static struct video_device qcam_template=
{
static struct video_device qcam_template = {
	.name		= "Connectix Quickcam",
	.fops           = &qcam_fops,
	.release 	= video_device_release_empty,
@@ -932,8 +896,7 @@ static int init_bwqcam(struct parport *port)
{
	struct qcam_device *qcam;

	if (num_cams == MAX_CAMS)
	{
	if (num_cams == MAX_CAMS) {
		printk(KERN_ERR "Too many Quickcams (max %d)\n", MAX_CAMS);
		return -ENOSPC;
	}
@@ -946,8 +909,7 @@ static int init_bwqcam(struct parport *port)

	qc_reset(qcam);

	if(qc_detect(qcam)==0)
	{
	if (qc_detect(qcam) == 0) {
		parport_release(qcam->pdev);
		parport_unregister_device(qcam->pdev);
		kfree(qcam);
@@ -1045,12 +1007,12 @@ static int __init init_bw_qcams(void)
#ifdef MODULE
	/* Do some sanity checks on the module parameters. */
	if (maxpoll > 5000) {
		printk("Connectix Quickcam max-poll was above 5000. Using 5000.\n");
		printk(KERN_INFO "Connectix Quickcam max-poll was above 5000. Using 5000.\n");
		maxpoll = 5000;
	}

	if (yieldlines < 1) {
		printk("Connectix Quickcam yieldlines was less than 1. Using 1.\n");
		printk(KERN_INFO "Connectix Quickcam yieldlines was less than 1. Using 1.\n");
		yieldlines = 1;
	}
#endif