Commit 046d747e authored by Timo von Holtz's avatar Timo von Holtz Committed by Greg Kroah-Hartman
Browse files

Staging: usbvideo: vicam: fixed some coding style issues



fixed coding style issues.

Signed-off-by: default avatarTimo von Holtz <tvh@informatik.uni-kiel.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 61ceb7f9
Loading
Loading
Loading
Loading
+79 −85
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@
#include <linux/ihex.h>
#include "usbvideo.h"

// #define VICAM_DEBUG
/* #define VICAM_DEBUG */

#ifdef VICAM_DEBUG
#define ADBG(lineno, fmt, args...) printk(fmt, jiffies, __func__, lineno, ##args)
@@ -118,15 +118,15 @@ static void rvfree(void *mem, unsigned long size)
}

struct vicam_camera {
	u16 shutter_speed;	// capture shutter speed
	u16 gain;		// capture gain
	u16 shutter_speed;	/* capture shutter speed */
	u16 gain;		/* capture gain */

	u8 *raw_image;		// raw data captured from the camera
	u8 *framebuf;		// processed data in RGB24 format
	u8 *cntrlbuf;		// area used to send control msgs
	u8 *raw_image;		/* raw data captured from the camera */
	u8 *framebuf;		/* processed data in RGB24 format */
	u8 *cntrlbuf;		/* area used to send control msgs */

	struct video_device vdev;	// v4l video device
	struct usb_device *udev;	// usb device
	struct video_device vdev;	/* v4l video device */
	struct usb_device *udev;	/* usb device */

	/* guard against simultaneous accesses to the camera */
	struct mutex cam_lock;
@@ -219,12 +219,12 @@ set_camera_power(struct vicam_camera *cam, int state)
{
	int status;

	if ((status = send_control_msg(cam, 0x50, state, 0, NULL, 0)) < 0)
	status = send_control_msg(cam, 0x50, state, 0, NULL, 0));
	if (status < 0)
		return status;

	if (state) {
	if (state)
		send_control_msg(cam, 0x55, 1, 0, NULL, 0);
	}

	return 0;
}
@@ -355,8 +355,8 @@ vicam_ioctl(struct file *file, unsigned int ioctlnr, unsigned long arg)
			if (copy_to_user(user_arg, (void *)&vw, sizeof(vw)))
				retval = -EFAULT;

			// I'm not sure what the deal with a capture window is, it is very poorly described
			// in the doc.  So I won't support it now.
			/* I'm not sure what the deal with a capture window is, it is very poorly described
			 * in the doc.  So I won't support it now. */
			break;
		}

@@ -401,23 +401,24 @@ vicam_ioctl(struct file *file, unsigned int ioctlnr, unsigned long arg)
	case VIDIOCMCAPTURE:
		{
			struct video_mmap vm;
			// int video_size;
			/* int video_size; */

			if (copy_from_user((void *)&vm, user_arg, sizeof(vm))) {
				retval = -EFAULT;
				break;
			}

			DBG("VIDIOCMCAPTURE frame=%d, height=%d, width=%d, format=%d.\n",vm.frame,vm.width,vm.height,vm.format);
			DBG("VIDIOCMCAPTURE frame=%d, height=%d, width=%d, format=%d.\n",
			    vm.frame, vm.width, vm.height, vm.format);

			if (vm.frame >= VICAM_FRAMES || vm.format != VIDEO_PALETTE_RGB24)
				retval = -EINVAL;

			// in theory right here we'd start the image capturing
			// (fill in a bulk urb and submit it asynchronously)
			//
			// Instead we're going to do a total hack job for now and
			// retrieve the frame in VIDIOCSYNC
			/* in theory right here we'd start the image capturing
			 * (fill in a bulk urb and submit it asynchronously)
			 *
			 * Instead we're going to do a total hack job for now and
			 * retrieve the frame in VIDIOCSYNC */

			break;
		}
@@ -522,7 +523,7 @@ vicam_open(struct file *file)
	mutex_unlock(&cam->cam_lock);


	// First upload firmware, then turn the camera on
	/* First upload firmware, then turn the camera on */

	if (!cam->is_initialized) {
		initialize_camera(cam);
@@ -562,9 +563,8 @@ vicam_close(struct file *file)

	mutex_unlock(&cam->cam_lock);

	if (!open_count && !udev) {
	if (!open_count && !udev)
		kfree(cam);
	}

	return 0;
}
@@ -588,9 +588,8 @@ static void vicam_decode_color(const u8 *data, u8 *rgb)
		int j, prevX, nextX;
		int Y, Cr, Cb;

		if ( y == 242 - 1 ) {
		if (y == 242 - 1)
			nextY = -512;
		}

		prevX = 1;
		nextX = 1;
@@ -599,9 +598,8 @@ static void vicam_decode_color(const u8 *data, u8 *rgb)
			const int x = (j * 512) / 320;
			const u8 * const src = &data[x];

			if ( x == 512 - 1 ) {
			if (x == 512 - 1)
				nextX = -1;
			}

			Cr = (src[prevX] - src[0]) +
				(src[nextX] - src[0]);
@@ -655,15 +653,15 @@ read_frame(struct vicam_camera *cam, int framenum)
	}

	memset(request, 0, 16);
	request[0] = cam->gain;	// 0 = 0% gain, FF = 100% gain
	request[0] = cam->gain;	/* 0 = 0% gain, FF = 100% gain */

	request[1] = 0;	// 512x242 capture
	request[1] = 0;	/* 512x242 capture */

	request[2] = 0x90;	// the function of these two bytes
	request[3] = 0x07;	// is not yet understood
	request[2] = 0x90;	/* the function of these two bytes */
	request[3] = 0x07;	/* is not yet understood */

	if (cam->shutter_speed > 60) {
		// Short exposure
		/* Short exposure */
		realShutter =
		    ((-15631900 / cam->shutter_speed) + 260533) / 1000;
		request[4] = realShutter & 0xFF;
@@ -671,7 +669,7 @@ read_frame(struct vicam_camera *cam, int framenum)
		request[6] = 0x03;
		request[7] = 0x01;
	} else {
		// Long exposure
		/* Long exposure */
		realShutter = 15600 / cam->shutter_speed - 1;
		request[4] = 0;
		request[5] = 0;
@@ -679,15 +677,14 @@ read_frame(struct vicam_camera *cam, int framenum)
		request[7] = realShutter >> 8;
	}

	// Per John Markus Bjørndalen, byte at index 8 causes problems if it isn't 0
	/* Per John Markus Bjørndalen, byte at index 8 causes problems if it isn't 0*/
	request[8] = 0;
	// bytes 9-15 do not seem to affect exposure or image quality
	/* bytes 9-15 do not seem to affect exposure or image quality */

	mutex_lock(&cam->cam_lock);

	if (!cam->udev) {
	if (!cam->udev)
		goto done;
	}

	n = __send_control_msg(cam, 0x51, 0x80, 0, request, 16);

@@ -732,15 +729,13 @@ vicam_read( struct file *file, char __user *buf, size_t count, loff_t *ppos )

	count = min_t(size_t, count, VICAM_MAX_FRAME_SIZE - *ppos);

	if (copy_to_user(buf, &cam->framebuf[*ppos], count)) {
	if (copy_to_user(buf, &cam->framebuf[*ppos], count))
		count = -EFAULT;
	} else {
	else
		*ppos += count;
	}

	if (count == VICAM_MAX_FRAME_SIZE) {
	if (count == VICAM_MAX_FRAME_SIZE)
		*ppos = 0;
	}

	return count;
}
@@ -749,7 +744,7 @@ vicam_read( struct file *file, char __user *buf, size_t count, loff_t *ppos )
static int
vicam_mmap(struct file *file, struct vm_area_struct *vma)
{
	// TODO: allocate the raw frame buffer if necessary
	/* TODO: allocate the raw frame buffer if necessary */
	unsigned long page, pos;
	unsigned long start = vma->vm_start;
	unsigned long size  = vma->vm_end-vma->vm_start;
@@ -847,8 +842,8 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id)
		       "No bulk in endpoint was found ?! (this is bad)\n");
	}

	if ((cam =
	     kzalloc(sizeof (struct vicam_camera), GFP_KERNEL)) == NULL) {
	cam = kzalloc(sizeof(struct vicam_camera), GFP_KERNEL);
	if (cam == NULL) {
		printk(KERN_WARNING
		       "could not allocate kernel memory for vicam_camera struct\n");
		return -ENOMEM;
@@ -914,9 +909,8 @@ vicam_disconnect(struct usb_interface *intf)

	mutex_unlock(&cam->cam_lock);

	if (!open_count) {
	if (!open_count)
		kfree(cam);
	}

	printk(KERN_DEBUG "ViCam-based WebCam disconnected\n");
}