Commit 61ceb7f9 authored by Timo von Holtz's avatar Timo von Holtz Committed by Greg Kroah-Hartman

Staging: usbvideo: usbvideo: 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 0ffbf8bf
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <asm/io.h> #include <linux/io.h>
#include "usbvideo.h" #include "usbvideo.h"
...@@ -112,9 +112,9 @@ static void RingQueue_Allocate(struct RingQueue *rq, int rqLen) ...@@ -112,9 +112,9 @@ static void RingQueue_Allocate(struct RingQueue *rq, int rqLen)
assert(rq != NULL); assert(rq != NULL);
assert(rqLen > 0); assert(rqLen > 0);
while(rqLen >> i) while (rqLen >> i)
i++; i++;
if(rqLen != 1 << (i-1)) if (rqLen != 1 << (i-1))
rqLen = 1 << i; rqLen = 1 << i;
rq->length = rqLen; rq->length = rqLen;
...@@ -148,15 +148,15 @@ int RingQueue_Dequeue(struct RingQueue *rq, unsigned char *dst, int len) ...@@ -148,15 +148,15 @@ int RingQueue_Dequeue(struct RingQueue *rq, unsigned char *dst, int len)
assert(dst != NULL); assert(dst != NULL);
rql = RingQueue_GetLength(rq); rql = RingQueue_GetLength(rq);
if(!rql) if (!rql)
return 0; return 0;
/* Clip requested length to available data */ /* Clip requested length to available data */
if(len > rql) if (len > rql)
len = rql; len = rql;
toread = len; toread = len;
if(rq->ri > rq->wi) { if (rq->ri > rq->wi) {
/* Read data from tail */ /* Read data from tail */
int read = (toread < (rq->length - rq->ri)) ? toread : rq->length - rq->ri; int read = (toread < (rq->length - rq->ri)) ? toread : rq->length - rq->ri;
memcpy(dst, rq->queue + rq->ri, read); memcpy(dst, rq->queue + rq->ri, read);
...@@ -164,7 +164,7 @@ int RingQueue_Dequeue(struct RingQueue *rq, unsigned char *dst, int len) ...@@ -164,7 +164,7 @@ int RingQueue_Dequeue(struct RingQueue *rq, unsigned char *dst, int len)
dst += read; dst += read;
rq->ri = (rq->ri + read) & (rq->length-1); rq->ri = (rq->ri + read) & (rq->length-1);
} }
if(toread) { if (toread) {
/* Read data from head */ /* Read data from head */
memcpy(dst, rq->queue + rq->ri, toread); memcpy(dst, rq->queue + rq->ri, toread);
rq->ri = (rq->ri + toread) & (rq->length-1); rq->ri = (rq->ri + toread) & (rq->length-1);
...@@ -292,12 +292,11 @@ static void usbvideo_OverlayChar(struct uvd *uvd, struct usbvideo_frame *frame, ...@@ -292,12 +292,11 @@ static void usbvideo_OverlayChar(struct uvd *uvd, struct usbvideo_frame *frame,
return; return;
digit = digits[value]; digit = digits[value];
for (iy=0; iy < 5; iy++) { for (iy = 0; iy < 5; iy++) {
for (ix=0; ix < 3; ix++) { for (ix = 0; ix < 3; ix++) {
if (digit & 0x8000) { if (digit & 0x8000) {
if (uvd->paletteBits & (1L << VIDEO_PALETTE_RGB24)) { if (uvd->paletteBits & (1L << VIDEO_PALETTE_RGB24))
/* TODO */ RGB24_PUTPIXEL(frame, x+ix, y+iy, 0xFF, 0xFF, 0xFF); /* TODO */ RGB24_PUTPIXEL(frame, x+ix, y+iy, 0xFF, 0xFF, 0xFF);
}
} }
digit = digit << 1; digit = digit << 1;
} }
...@@ -332,7 +331,7 @@ static void usbvideo_OverlayStats(struct uvd *uvd, struct usbvideo_frame *frame) ...@@ -332,7 +331,7 @@ static void usbvideo_OverlayStats(struct uvd *uvd, struct usbvideo_frame *frame)
{ {
const int y_diff = 8; const int y_diff = 8;
char tmp[16]; char tmp[16];
int x = 10, y=10; int x = 10, y = 10;
long i, j, barLength; long i, j, barLength;
const int qi_x1 = 60, qi_y1 = 10; const int qi_x1 = 60, qi_y1 = 10;
const int qi_x2 = VIDEOSIZE_X(frame->request) - 10, qi_h = 10; const int qi_x2 = VIDEOSIZE_X(frame->request) - 10, qi_h = 10;
...@@ -375,8 +374,8 @@ static void usbvideo_OverlayStats(struct uvd *uvd, struct usbvideo_frame *frame) ...@@ -375,8 +374,8 @@ static void usbvideo_OverlayStats(struct uvd *uvd, struct usbvideo_frame *frame)
m_lo = (u_lo > 0) ? (qi_x1 + ((barLength * u_lo) / uvd->dp.length)) : -1; m_lo = (u_lo > 0) ? (qi_x1 + ((barLength * u_lo) / uvd->dp.length)) : -1;
m_hi = qi_x1 + ((barLength * u_hi) / uvd->dp.length); m_hi = qi_x1 + ((barLength * u_hi) / uvd->dp.length);
for (j=qi_y1; j < (qi_y1 + qi_h); j++) { for (j = qi_y1; j < (qi_y1 + qi_h); j++) {
for (i=qi_x1; i < qi_x2; i++) { for (i = qi_x1; i < qi_x2; i++) {
/* Draw border lines */ /* Draw border lines */
if ((j == qi_y1) || (j == (qi_y1 + qi_h - 1)) || if ((j == qi_y1) || (j == (qi_y1 + qi_h - 1)) ||
(i == qi_x1) || (i == (qi_x2 - 1))) { (i == qi_x1) || (i == (qi_x2 - 1))) {
...@@ -384,11 +383,11 @@ static void usbvideo_OverlayStats(struct uvd *uvd, struct usbvideo_frame *frame) ...@@ -384,11 +383,11 @@ static void usbvideo_OverlayStats(struct uvd *uvd, struct usbvideo_frame *frame)
continue; continue;
} }
/* For all other points the Y coordinate does not matter */ /* For all other points the Y coordinate does not matter */
if ((i >= m_ri) && (i <= (m_ri + 3))) { if ((i >= m_ri) && (i <= (m_ri + 3)))
RGB24_PUTPIXEL(frame, i, j, 0x00, 0xFF, 0x00); RGB24_PUTPIXEL(frame, i, j, 0x00, 0xFF, 0x00);
} else if ((i >= m_wi) && (i <= (m_wi + 3))) { else if ((i >= m_wi) && (i <= (m_wi + 3)))
RGB24_PUTPIXEL(frame, i, j, 0xFF, 0x00, 0x00); RGB24_PUTPIXEL(frame, i, j, 0xFF, 0x00, 0x00);
} else if ((i < m_lo) || ((i > m_ri) && (i < m_hi))) else if ((i < m_lo) || ((i > m_ri) && (i < m_hi)))
RGB24_PUTPIXEL(frame, i, j, 0x00, 0x00, 0xFF); RGB24_PUTPIXEL(frame, i, j, 0x00, 0x00, 0xFF);
} }
} }
...@@ -551,8 +550,8 @@ void usbvideo_TestPattern(struct uvd *uvd, int fullframe, int pmode) ...@@ -551,8 +550,8 @@ void usbvideo_TestPattern(struct uvd *uvd, int fullframe, int pmode)
int i; int i;
unsigned char *f = frame->data + unsigned char *f = frame->data +
(VIDEOSIZE_X(frame->request) * V4L_BYTES_PER_PIXEL * frame->curline); (VIDEOSIZE_X(frame->request) * V4L_BYTES_PER_PIXEL * frame->curline);
for (i=0; i < VIDEOSIZE_X(frame->request); i++) { for (i = 0; i < VIDEOSIZE_X(frame->request); i++) {
unsigned char cb=0x80; unsigned char cb = 0x80;
unsigned char cg = 0; unsigned char cg = 0;
unsigned char cr = 0; unsigned char cr = 0;
...@@ -605,10 +604,10 @@ void usbvideo_HexDump(const unsigned char *data, int len) ...@@ -605,10 +604,10 @@ void usbvideo_HexDump(const unsigned char *data, int len)
char tmp[128]; /* 32*3 + 5 */ char tmp[128]; /* 32*3 + 5 */
int i, k; int i, k;
for (i=k=0; len > 0; i++, len--) { for (i = k = 0; len > 0; i++, len--) {
if (i > 0 && ((i % bytes_per_line) == 0)) { if (i > 0 && ((i % bytes_per_line) == 0)) {
printk("%s\n", tmp); printk("%s\n", tmp);
k=0; k = 0;
} }
if ((i % bytes_per_line) == 0) if ((i % bytes_per_line) == 0)
k += sprintf(&tmp[k], "%04x: ", i); k += sprintf(&tmp[k], "%04x: ", i);
...@@ -787,7 +786,7 @@ void usbvideo_Deregister(struct usbvideo **pCams) ...@@ -787,7 +786,7 @@ void usbvideo_Deregister(struct usbvideo **pCams)
usb_deregister(&cams->usbdrv); usb_deregister(&cams->usbdrv);
dbg("%s: Deallocating cams=$%p (%d. cameras)", __func__, cams, cams->num_cameras); dbg("%s: Deallocating cams=$%p (%d. cameras)", __func__, cams, cams->num_cameras);
for (i=0; i < cams->num_cameras; i++) { for (i = 0; i < cams->num_cameras; i++) {
struct uvd *up = &cams->cam[i]; struct uvd *up = &cams->cam[i];
int warning = 0; int warning = 0;
...@@ -840,7 +839,7 @@ EXPORT_SYMBOL(usbvideo_Deregister); ...@@ -840,7 +839,7 @@ EXPORT_SYMBOL(usbvideo_Deregister);
*/ */
static void usbvideo_Disconnect(struct usb_interface *intf) static void usbvideo_Disconnect(struct usb_interface *intf)
{ {
struct uvd *uvd = usb_get_intfdata (intf); struct uvd *uvd = usb_get_intfdata(intf);
int i; int i;
if (uvd == NULL) { if (uvd == NULL) {
...@@ -848,7 +847,7 @@ static void usbvideo_Disconnect(struct usb_interface *intf) ...@@ -848,7 +847,7 @@ static void usbvideo_Disconnect(struct usb_interface *intf)
return; return;
} }
usb_set_intfdata (intf, NULL); usb_set_intfdata(intf, NULL);
usbvideo_ClientIncModCount(uvd); usbvideo_ClientIncModCount(uvd);
if (uvd->debug > 0) if (uvd->debug > 0)
...@@ -860,11 +859,11 @@ static void usbvideo_Disconnect(struct usb_interface *intf) ...@@ -860,11 +859,11 @@ static void usbvideo_Disconnect(struct usb_interface *intf)
/* At this time we ask to cancel outstanding URBs */ /* At this time we ask to cancel outstanding URBs */
GET_CALLBACK(uvd, stopDataPump)(uvd); GET_CALLBACK(uvd, stopDataPump)(uvd);
for (i=0; i < USBVIDEO_NUMSBUF; i++) for (i = 0; i < USBVIDEO_NUMSBUF; i++)
usb_free_urb(uvd->sbuf[i].urb); usb_free_urb(uvd->sbuf[i].urb);
usb_put_dev(uvd->dev); usb_put_dev(uvd->dev);
uvd->dev = NULL; /* USB device is no more */ uvd->dev = NULL; /* USB device is no more */
video_unregister_device(&uvd->vdev); video_unregister_device(&uvd->vdev);
if (uvd->debug > 0) if (uvd->debug > 0)
...@@ -925,8 +924,7 @@ static int usbvideo_find_struct(struct usbvideo *cams) ...@@ -925,8 +924,7 @@ static int usbvideo_find_struct(struct usbvideo *cams)
mutex_lock(&cams->lock); mutex_lock(&cams->lock);
for (u = 0; u < cams->num_cameras; u++) { for (u = 0; u < cams->num_cameras; u++) {
struct uvd *uvd = &cams->cam[u]; struct uvd *uvd = &cams->cam[u];
if (!uvd->uvd_used) /* This one is free */ if (!uvd->uvd_used) { /* This one is free */
{
uvd->uvd_used = 1; /* In use now */ uvd->uvd_used = 1; /* In use now */
mutex_init(&uvd->lock); /* to 1 == available */ mutex_init(&uvd->lock); /* to 1 == available */
uvd->dev = NULL; uvd->dev = NULL;
...@@ -941,10 +939,10 @@ static int usbvideo_find_struct(struct usbvideo *cams) ...@@ -941,10 +939,10 @@ static int usbvideo_find_struct(struct usbvideo *cams)
static const struct v4l2_file_operations usbvideo_fops = { static const struct v4l2_file_operations usbvideo_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = usbvideo_v4l_open, .open = usbvideo_v4l_open,
.release =usbvideo_v4l_close, .release = usbvideo_v4l_close,
.read = usbvideo_v4l_read, .read = usbvideo_v4l_read,
.mmap = usbvideo_v4l_mmap, .mmap = usbvideo_v4l_mmap,
.ioctl = usbvideo_v4l_ioctl, .ioctl = usbvideo_v4l_ioctl,
}; };
static const struct video_device usbvideo_template = { static const struct video_device usbvideo_template = {
.fops = &usbvideo_fops, .fops = &usbvideo_fops,
...@@ -972,7 +970,7 @@ struct uvd *usbvideo_AllocateDevice(struct usbvideo *cams) ...@@ -972,7 +970,7 @@ struct uvd *usbvideo_AllocateDevice(struct usbvideo *cams)
usbvideo_ClientIncModCount(uvd); usbvideo_ClientIncModCount(uvd);
mutex_lock(&uvd->lock); mutex_lock(&uvd->lock);
for (i=0; i < USBVIDEO_NUMSBUF; i++) { for (i = 0; i < USBVIDEO_NUMSBUF; i++) {
uvd->sbuf[i].urb = usb_alloc_urb(FRAMES_PER_DESC, GFP_KERNEL); uvd->sbuf[i].urb = usb_alloc_urb(FRAMES_PER_DESC, GFP_KERNEL);
if (uvd->sbuf[i].urb == NULL) { if (uvd->sbuf[i].urb == NULL) {
err("usb_alloc_urb(%d.) failed.", FRAMES_PER_DESC); err("usb_alloc_urb(%d.) failed.", FRAMES_PER_DESC);
...@@ -981,7 +979,7 @@ struct uvd *usbvideo_AllocateDevice(struct usbvideo *cams) ...@@ -981,7 +979,7 @@ struct uvd *usbvideo_AllocateDevice(struct usbvideo *cams)
goto allocate_done; goto allocate_done;
} }
} }
uvd->user=0; uvd->user = 0;
uvd->remove_pending = 0; uvd->remove_pending = 0;
uvd->last_error = 0; uvd->last_error = 0;
RingQueue_Initialize(&uvd->dp); RingQueue_Initialize(&uvd->dp);
...@@ -1127,7 +1125,7 @@ static int usbvideo_v4l_open(struct file *file) ...@@ -1127,7 +1125,7 @@ static int usbvideo_v4l_open(struct file *file)
memset(&uvd->stats, 0, sizeof(uvd->stats)); memset(&uvd->stats, 0, sizeof(uvd->stats));
/* Clean pointers so we know if we allocated something */ /* Clean pointers so we know if we allocated something */
for (i=0; i < USBVIDEO_NUMSBUF; i++) for (i = 0; i < USBVIDEO_NUMSBUF; i++)
uvd->sbuf[i].data = NULL; uvd->sbuf[i].data = NULL;
/* Allocate memory for the frame buffers */ /* Allocate memory for the frame buffers */
...@@ -1140,7 +1138,7 @@ static int usbvideo_v4l_open(struct file *file) ...@@ -1140,7 +1138,7 @@ static int usbvideo_v4l_open(struct file *file)
errCode = -ENOMEM; errCode = -ENOMEM;
} else { } else {
/* Allocate all buffers */ /* Allocate all buffers */
for (i=0; i < USBVIDEO_NUMFRAMES; i++) { for (i = 0; i < USBVIDEO_NUMFRAMES; i++) {
uvd->frame[i].frameState = FrameState_Unused; uvd->frame[i].frameState = FrameState_Unused;
uvd->frame[i].data = uvd->fbuf + i*(uvd->max_frame_size); uvd->frame[i].data = uvd->fbuf + i*(uvd->max_frame_size);
/* /*
...@@ -1150,7 +1148,7 @@ static int usbvideo_v4l_open(struct file *file) ...@@ -1150,7 +1148,7 @@ static int usbvideo_v4l_open(struct file *file)
uvd->frame[i].canvas = uvd->canvas; uvd->frame[i].canvas = uvd->canvas;
uvd->frame[i].seqRead_Index = 0; uvd->frame[i].seqRead_Index = 0;
} }
for (i=0; i < USBVIDEO_NUMSBUF; i++) { for (i = 0; i < USBVIDEO_NUMSBUF; i++) {
uvd->sbuf[i].data = kmalloc(sb_size, GFP_KERNEL); uvd->sbuf[i].data = kmalloc(sb_size, GFP_KERNEL);
if (uvd->sbuf[i].data == NULL) { if (uvd->sbuf[i].data == NULL) {
errCode = -ENOMEM; errCode = -ENOMEM;
...@@ -1165,7 +1163,7 @@ static int usbvideo_v4l_open(struct file *file) ...@@ -1165,7 +1163,7 @@ static int usbvideo_v4l_open(struct file *file)
uvd->fbuf = NULL; uvd->fbuf = NULL;
} }
RingQueue_Free(&uvd->dp); RingQueue_Free(&uvd->dp);
for (i=0; i < USBVIDEO_NUMSBUF; i++) { for (i = 0; i < USBVIDEO_NUMSBUF; i++) {
kfree(uvd->sbuf[i].data); kfree(uvd->sbuf[i].data);
uvd->sbuf[i].data = NULL; uvd->sbuf[i].data = NULL;
} }
...@@ -1240,7 +1238,7 @@ static int usbvideo_v4l_close(struct file *file) ...@@ -1240,7 +1238,7 @@ static int usbvideo_v4l_close(struct file *file)
uvd->fbuf = NULL; uvd->fbuf = NULL;
RingQueue_Free(&uvd->dp); RingQueue_Free(&uvd->dp);
for (i=0; i < USBVIDEO_NUMSBUF; i++) { for (i = 0; i < USBVIDEO_NUMSBUF; i++) {
kfree(uvd->sbuf[i].data); kfree(uvd->sbuf[i].data);
uvd->sbuf[i].data = NULL; uvd->sbuf[i].data = NULL;
} }
...@@ -1281,32 +1279,32 @@ static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg ...@@ -1281,32 +1279,32 @@ static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg
return -EIO; return -EIO;
switch (cmd) { switch (cmd) {
case VIDIOCGCAP: case VIDIOCGCAP:
{ {
struct video_capability *b = arg; struct video_capability *b = arg;
*b = uvd->vcap; *b = uvd->vcap;
return 0; return 0;
} }
case VIDIOCGCHAN: case VIDIOCGCHAN:
{ {
struct video_channel *v = arg; struct video_channel *v = arg;
*v = uvd->vchan; *v = uvd->vchan;
return 0; return 0;
} }
case VIDIOCSCHAN: case VIDIOCSCHAN:
{ {
struct video_channel *v = arg; struct video_channel *v = arg;
if (v->channel != 0) if (v->channel != 0)
return -EINVAL; return -EINVAL;
return 0; return 0;
} }
case VIDIOCGPICT: case VIDIOCGPICT:
{ {
struct video_picture *pic = arg; struct video_picture *pic = arg;
*pic = uvd->vpic; *pic = uvd->vpic;
return 0; return 0;
} }
case VIDIOCSPICT: case VIDIOCSPICT:
{ {
struct video_picture *pic = arg; struct video_picture *pic = arg;
/* /*
...@@ -1321,13 +1319,12 @@ static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg ...@@ -1321,13 +1319,12 @@ static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg
uvd->settingsAdjusted = 0; /* Will force new settings */ uvd->settingsAdjusted = 0; /* Will force new settings */
return 0; return 0;
} }
case VIDIOCSWIN: case VIDIOCSWIN:
{ {
struct video_window *vw = arg; struct video_window *vw = arg;
if(VALID_CALLBACK(uvd, setVideoMode)) { if (VALID_CALLBACK(uvd, setVideoMode))
return GET_CALLBACK(uvd, setVideoMode)(uvd, vw); return GET_CALLBACK(uvd, setVideoMode)(uvd, vw);
}
if (vw->flags) if (vw->flags)
return -EINVAL; return -EINVAL;
...@@ -1340,7 +1337,7 @@ static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg ...@@ -1340,7 +1337,7 @@ static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg
return 0; return 0;
} }
case VIDIOCGWIN: case VIDIOCGWIN:
{ {
struct video_window *vw = arg; struct video_window *vw = arg;
...@@ -1355,7 +1352,7 @@ static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg ...@@ -1355,7 +1352,7 @@ static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg
vw->flags = 10; /* FIXME: do better! */ vw->flags = 10; /* FIXME: do better! */
return 0; return 0;
} }
case VIDIOCGMBUF: case VIDIOCGMBUF:
{ {
struct video_mbuf *vm = arg; struct video_mbuf *vm = arg;
int i; int i;
...@@ -1363,12 +1360,12 @@ static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg ...@@ -1363,12 +1360,12 @@ static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg
memset(vm, 0, sizeof(*vm)); memset(vm, 0, sizeof(*vm));
vm->size = uvd->max_frame_size * USBVIDEO_NUMFRAMES; vm->size = uvd->max_frame_size * USBVIDEO_NUMFRAMES;
vm->frames = USBVIDEO_NUMFRAMES; vm->frames = USBVIDEO_NUMFRAMES;
for(i = 0; i < USBVIDEO_NUMFRAMES; i++) for (i = 0; i < USBVIDEO_NUMFRAMES; i++)
vm->offsets[i] = i * uvd->max_frame_size; vm->offsets[i] = i * uvd->max_frame_size;
return 0; return 0;
} }
case VIDIOCMCAPTURE: case VIDIOCMCAPTURE:
{ {
struct video_mmap *vm = arg; struct video_mmap *vm = arg;
...@@ -1429,7 +1426,7 @@ static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg ...@@ -1429,7 +1426,7 @@ static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg
return usbvideo_NewFrame(uvd, vm->frame); return usbvideo_NewFrame(uvd, vm->frame);
} }
case VIDIOCSYNC: case VIDIOCSYNC:
{ {
int *frameNum = arg; int *frameNum = arg;
int ret; int ret;
...@@ -1445,9 +1442,8 @@ static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg ...@@ -1445,9 +1442,8 @@ static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg
ret = usbvideo_GetFrame(uvd, *frameNum); ret = usbvideo_GetFrame(uvd, *frameNum);
else if (VALID_CALLBACK(uvd, getFrame)) { else if (VALID_CALLBACK(uvd, getFrame)) {
ret = GET_CALLBACK(uvd, getFrame)(uvd, *frameNum); ret = GET_CALLBACK(uvd, getFrame)(uvd, *frameNum);
if ((ret < 0) && (uvd->debug >= 1)) { if ((ret < 0) && (uvd->debug >= 1))
err("VIDIOCSYNC: getFrame() returned %d.", ret); err("VIDIOCSYNC: getFrame() returned %d.", ret);
}
} else { } else {
err("VIDIOCSYNC: getFrame is not set"); err("VIDIOCSYNC: getFrame is not set");
ret = -EFAULT; ret = -EFAULT;
...@@ -1462,33 +1458,33 @@ static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg ...@@ -1462,33 +1458,33 @@ static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg
uvd->frame[*frameNum].frameState = FrameState_Unused; uvd->frame[*frameNum].frameState = FrameState_Unused;
return ret; return ret;
} }
case VIDIOCGFBUF: case VIDIOCGFBUF:
{ {
struct video_buffer *vb = arg; struct video_buffer *vb = arg;
memset(vb, 0, sizeof(*vb)); memset(vb, 0, sizeof(*vb));
return 0; return 0;
} }
case VIDIOCKEY: case VIDIOCKEY:
return 0; return 0;
case VIDIOCCAPTURE: case VIDIOCCAPTURE:
return -EINVAL; return -EINVAL;
case VIDIOCSFBUF: case VIDIOCSFBUF:
case VIDIOCGTUNER: case VIDIOCGTUNER:
case VIDIOCSTUNER: case VIDIOCSTUNER:
case VIDIOCGFREQ: case VIDIOCGFREQ:
case VIDIOCSFREQ: case VIDIOCSFREQ:
case VIDIOCGAUDIO: case VIDIOCGAUDIO:
case VIDIOCSAUDIO: case VIDIOCSAUDIO:
return -EINVAL; return -EINVAL;
default: default:
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
return 0; return 0;
} }
...@@ -1529,7 +1525,7 @@ static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf, ...@@ -1529,7 +1525,7 @@ static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf,
mutex_lock(&uvd->lock); mutex_lock(&uvd->lock);
/* See if a frame is completed, then use it. */ /* See if a frame is completed, then use it. */
for(i = 0; i < USBVIDEO_NUMFRAMES; i++) { for (i = 0; i < USBVIDEO_NUMFRAMES; i++) {
if ((uvd->frame[i].frameState == FrameState_Done) || if ((uvd->frame[i].frameState == FrameState_Done) ||
(uvd->frame[i].frameState == FrameState_Done_Hold) || (uvd->frame[i].frameState == FrameState_Done_Hold) ||
(uvd->frame[i].frameState == FrameState_Error)) { (uvd->frame[i].frameState == FrameState_Error)) {
...@@ -1550,7 +1546,7 @@ static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf, ...@@ -1550,7 +1546,7 @@ static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf,
* We will need to wait until it becomes cooked, of course. * We will need to wait until it becomes cooked, of course.
*/ */
if (frmx == -1) { if (frmx == -1) {
for(i = 0; i < USBVIDEO_NUMFRAMES; i++) { for (i = 0; i < USBVIDEO_NUMFRAMES; i++) {
if (uvd->frame[i].frameState == FrameState_Grabbing) { if (uvd->frame[i].frameState == FrameState_Grabbing) {
frmx = i; frmx = i;
break; break;
...@@ -1653,9 +1649,8 @@ static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf, ...@@ -1653,9 +1649,8 @@ static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf,
/* Mark it as available to be used again. */ /* Mark it as available to be used again. */
uvd->frame[frmx].frameState = FrameState_Unused; uvd->frame[frmx].frameState = FrameState_Unused;
if (usbvideo_NewFrame(uvd, (frmx + 1) % USBVIDEO_NUMFRAMES)) { if (usbvideo_NewFrame(uvd, (frmx + 1) % USBVIDEO_NUMFRAMES))
err("%s: usbvideo_NewFrame failed.", __func__); err("%s: usbvideo_NewFrame failed.", __func__);
}
} }
read_done: read_done:
mutex_unlock(&uvd->lock); mutex_unlock(&uvd->lock);
...@@ -1744,8 +1739,8 @@ static void usbvideo_IsocIrq(struct urb *urb) ...@@ -1744,8 +1739,8 @@ static void usbvideo_IsocIrq(struct urb *urb)
} }
urb->status = 0; urb->status = 0;
urb->dev = uvd->dev; urb->dev = uvd->dev;
ret = usb_submit_urb (urb, GFP_KERNEL); ret = usb_submit_urb(urb, GFP_KERNEL);
if(ret) if (ret)
err("usb_submit_urb error (%d)", ret); err("usb_submit_urb error (%d)", ret);
return; return;
} }
...@@ -1785,7 +1780,7 @@ static int usbvideo_StartDataPump(struct uvd *uvd) ...@@ -1785,7 +1780,7 @@ static int usbvideo_StartDataPump(struct uvd *uvd)
err("%s: videoStart not set", __func__); err("%s: videoStart not set", __func__);
/* We double buffer the Iso lists */ /* We double buffer the Iso lists */
for (i=0; i < USBVIDEO_NUMSBUF; i++) { for (i = 0; i < USBVIDEO_NUMSBUF; i++) {
int j, k; int j, k;
struct urb *urb = uvd->sbuf[i].urb; struct urb *urb = uvd->sbuf[i].urb;
urb->dev = dev; urb->dev = dev;
...@@ -1797,14 +1792,14 @@ static int usbvideo_StartDataPump(struct uvd *uvd) ...@@ -1797,14 +1792,14 @@ static int usbvideo_StartDataPump(struct uvd *uvd)
urb->complete = usbvideo_IsocIrq; urb->complete = usbvideo_IsocIrq;
urb->number_of_packets = FRAMES_PER_DESC; urb->number_of_packets = FRAMES_PER_DESC;
urb->transfer_buffer_length = uvd->iso_packet_len * FRAMES_PER_DESC; urb->transfer_buffer_length = uvd->iso_packet_len * FRAMES_PER_DESC;
for (j=k=0; j < FRAMES_PER_DESC; j++, k += uvd->iso_packet_len) { for (j = k = 0; j < FRAMES_PER_DESC; j++, k += uvd->iso_packet_len) {
urb->iso_frame_desc[j].offset = k; urb->iso_frame_desc[j].offset = k;
urb->iso_frame_desc[j].length = uvd->iso_packet_len; urb->iso_frame_desc[j].length = uvd->iso_packet_len;
} }
} }
/* Submit all URBs */ /* Submit all URBs */
for (i=0; i < USBVIDEO_NUMSBUF; i++) { for (i = 0; i < USBVIDEO_NUMSBUF; i++) {
errFlag = usb_submit_urb(uvd->sbuf[i].urb, GFP_KERNEL); errFlag = usb_submit_urb(uvd->sbuf[i].urb, GFP_KERNEL);
if (errFlag) if (errFlag)
err("%s: usb_submit_isoc(%d) ret %d", __func__, i, errFlag); err("%s: usb_submit_isoc(%d) ret %d", __func__, i, errFlag);
...@@ -1839,9 +1834,8 @@ static void usbvideo_StopDataPump(struct uvd *uvd) ...@@ -1839,9 +1834,8 @@ static void usbvideo_StopDataPump(struct uvd *uvd)
dev_info(&uvd->dev->dev, "%s($%p)\n", __func__, uvd); dev_info(&uvd->dev->dev, "%s($%p)\n", __func__, uvd);
/* Unschedule all of the iso td's */ /* Unschedule all of the iso td's */
for (i=0; i < USBVIDEO_NUMSBUF; i++) { for (i = 0; i < USBVIDEO_NUMSBUF; i++)
usb_kill_urb(uvd->sbuf[i].urb); usb_kill_urb(uvd->sbuf[i].urb);
}
if (uvd->debug > 1) if (uvd->debug > 1)
dev_info(&uvd->dev->dev, "%s: streaming=0\n", __func__); dev_info(&uvd->dev->dev, "%s: streaming=0\n", __func__);
uvd->streaming = 0; uvd->streaming = 0;
...@@ -1995,7 +1989,7 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum) ...@@ -1995,7 +1989,7 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum)
case FrameState_Error: case FrameState_Error:
{ {
int ntries, signalPending; int ntries, signalPending;
redo: redo:
if (!CAMERA_IS_OPERATIONAL(uvd)) { if (!CAMERA_IS_OPERATIONAL(uvd)) {
if (uvd->debug >= 2) if (uvd->debug >= 2)
dev_info(&uvd->dev->dev, dev_info(&uvd->dev->dev,
...@@ -2133,8 +2127,7 @@ void usbvideo_DeinterlaceFrame(struct uvd *uvd, struct usbvideo_frame *frame) ...@@ -2133,8 +2127,7 @@ void usbvideo_DeinterlaceFrame(struct uvd *uvd, struct usbvideo_frame *frame)
return; return;
if ((frame->deinterlace == Deinterlace_FillEvenLines) || if ((frame->deinterlace == Deinterlace_FillEvenLines) ||
(frame->deinterlace == Deinterlace_FillOddLines)) (frame->deinterlace == Deinterlace_FillOddLines)) {
{
const int v4l_linesize = VIDEOSIZE_X(frame->request) * V4L_BYTES_PER_PIXEL; const int v4l_linesize = VIDEOSIZE_X(frame->request) * V4L_BYTES_PER_PIXEL;
int i = (frame->deinterlace == Deinterlace_FillEvenLines) ? 0 : 1; int i = (frame->deinterlace == Deinterlace_FillEvenLines) ? 0 : 1;
...@@ -2160,8 +2153,7 @@ void usbvideo_DeinterlaceFrame(struct uvd *uvd, struct usbvideo_frame *frame) ...@@ -2160,8 +2153,7 @@ void usbvideo_DeinterlaceFrame(struct uvd *uvd, struct usbvideo_frame *frame)
/* Sanity check */ /* Sanity check */
if ((ip < 0) || (in < 0) || if ((ip < 0) || (in < 0) ||
(ip >= VIDEOSIZE_Y(frame->request)) || (ip >= VIDEOSIZE_Y(frame->request)) ||
(in >= VIDEOSIZE_Y(frame->request))) (in >= VIDEOSIZE_Y(frame->request))) {
{
err("Error: ip=%d. in=%d. req.height=%ld.", err("Error: ip=%d. in=%d. req.height=%ld.",
ip, in, VIDEOSIZE_Y(frame->request)); ip, in, VIDEOSIZE_Y(frame->request));
break; break;
...@@ -2173,7 +2165,7 @@ void usbvideo_DeinterlaceFrame(struct uvd *uvd, struct usbvideo_frame *frame) ...@@ -2173,7 +2165,7 @@ void usbvideo_DeinterlaceFrame(struct uvd *uvd, struct usbvideo_frame *frame)
fd = frame->data + (v4l_linesize * i); fd = frame->data + (v4l_linesize * i);
/* Average lines around destination */ /* Average lines around destination */
for (j=0; j < v4l_linesize; j++) { for (j = 0; j < v4l_linesize; j++) {
fd[j] = (unsigned char)((((unsigned) fs1[j]) + fd[j] = (unsigned char)((((unsigned) fs1[j]) +
((unsigned)fs2[j])) >> 1); ((unsigned)fs2[j])) >> 1);
} }
...@@ -2215,9 +2207,9 @@ static void usbvideo_SoftwareContrastAdjustment(struct uvd *uvd, ...@@ -2215,9 +2207,9 @@ static void usbvideo_SoftwareContrastAdjustment(struct uvd *uvd,
return; return;
} }
v4l_linesize = VIDEOSIZE_X(frame->request) * V4L_BYTES_PER_PIXEL; v4l_linesize = VIDEOSIZE_X(frame->request) * V4L_BYTES_PER_PIXEL;
for (i=0; i < VIDEOSIZE_Y(frame->request); i++) { for (i = 0; i < VIDEOSIZE_Y(frame->request); i++) {
unsigned char *fd = frame->data + (v4l_linesize * i); unsigned char *fd = frame->data + (v4l_linesize * i);
for (j=0; j < v4l_linesize; j++) { for (j = 0; j < v4l_linesize; j++) {
signed long v = (signed long) fd[j]; signed long v = (signed long) fd[j];
/* Magnify up to 2 times, reduce down to zero */ /* Magnify up to 2 times, reduce down to zero */
v = 128 + ((ccm + adj) * (v - 128)) / ccm; v = 128 + ((ccm + adj) * (v - 128)) / ccm;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment