V4L/DVB (6758): Miscelaneous cleanups

Manually fixed all pertinent checkpatch.pl errors inside the source code.

Also removed some unused code at the driver and a few minor cleanups.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This commit is contained in:
Mauro Carvalho Chehab
2007-12-10 09:33:52 -03:00
parent 025341d4f0
commit 543323bcf4

View File

@@ -44,16 +44,13 @@
#define WAKE_DENOMINATOR 1001
#define BUFFER_TIMEOUT msecs_to_jiffies(500) /* 0.5 seconds */
/* These timers are for 1 fps - used only for testing */
//#define WAKE_DENOMINATOR 30 /* hack for testing purposes */
//#define BUFFER_TIMEOUT msecs_to_jiffies(5000) /* 5 seconds */
#include "font.h"
#define VIVI_MAJOR_VERSION 0
#define VIVI_MINOR_VERSION 4
#define VIVI_RELEASE 0
#define VIVI_VERSION KERNEL_VERSION(VIVI_MAJOR_VERSION, VIVI_MINOR_VERSION, VIVI_RELEASE)
#define VIVI_VERSION \
KERNEL_VERSION(VIVI_MAJOR_VERSION, VIVI_MINOR_VERSION, VIVI_RELEASE)
/* Declare static vars that will be used as parameters */
static unsigned int vid_limit = 16; /* Video memory limit, in Mb */
@@ -206,7 +203,8 @@ enum colors {
GREEN,
MAGENTA,
RED,
BLUE
BLUE,
BLACK,
};
static u8 bars[8][3] = {
@@ -218,14 +216,17 @@ static u8 bars[8][3] = {
{239, 0, 239}, /* magenta */
{205, 0, 0}, /* red */
{ 0, 0, 255}, /* blue */
{ 0, 0, 0}
{ 0, 0, 0}, /* black */
};
#define TO_Y(r,g,b) (((16829*r +33039*g +6416*b + 32768)>>16)+16)
#define TO_Y(r, g, b) \
(((16829 * r + 33039 * g + 6416 * b + 32768) >> 16) + 16)
/* RGB to V(Cr) Color transform */
#define TO_V(r,g,b) (((28784*r -24103*g -4681*b + 32768)>>16)+128)
#define TO_V(r, g, b) \
(((28784 * r - 24103 * g - 4681 * b + 32768) >> 16) + 128)
/* RGB to U(Cb) Color transform */
#define TO_U(r,g,b) (((-9714*r -19070*g +28784*b + 32768)>>16)+128)
#define TO_U(r, g, b) \
(((-9714 * r - 19070 * g + 28784 * b + 32768) >> 16) + 128)
#define TSTAMP_MIN_Y 24
#define TSTAMP_MAX_Y TSTAMP_MIN_Y+15
@@ -234,7 +235,8 @@ static u8 bars[8][3] = {
static void gen_line(char *basep, int inipos, int wmax,
int hmax, int line, int count, char *timestr)
{
int w,i,j,pos=inipos,y;
int w, i, j, y;
int pos = inipos;
char *p, *s;
u8 chr, r, g, b, color;
@@ -254,7 +256,7 @@ static void gen_line(char *basep,int inipos,int wmax,
switch (color) {
case 0:
case 2:
*p=TO_Y(r,g,b); /* Luminance */
*p = TO_Y(r, g, b); /* Luma */
break;
case 1:
*p = TO_U(r, g, b); /* Cb */
@@ -279,17 +281,16 @@ static void gen_line(char *basep,int inipos,int wmax,
for (s = timestr; *s; s++) {
chr = rom8x16_bits[(*s-0x30)*16+line-TSTAMP_MIN_Y];
for (i = 0; i < 7; i++) {
if (chr&1<<(7-i)) { /* Font color*/
r=bars[BLUE][0];
g=bars[BLUE][1];
b=bars[BLUE][2];
r=g=b=0;
if (chr & 1 << (7 - i)) {
/* Font color*/
r = 0;
g = 198;
} else { /* Background color */
r=bars[WHITE][0];
g=bars[WHITE][1];
b=bars[WHITE][2];
r=g=b=0;
b = 0;
} else {
/* Background color */
r = bars[BLACK][0];
g = bars[BLACK][1];
b = bars[BLACK][2];
}
pos = inipos + j * 2;
@@ -301,7 +302,7 @@ static void gen_line(char *basep,int inipos,int wmax,
switch (color) {
case 0:
case 2:
*p=TO_Y(r,g,b); /* Luminance */
*p = TO_Y(r, g, b); /* Luma */
break;
case 1:
*p = TO_U(r, g, b); /* Cb */
@@ -317,7 +318,6 @@ static void gen_line(char *basep,int inipos,int wmax,
}
}
end:
return;
}
@@ -418,7 +418,8 @@ static void vivi_thread_tick(struct vivi_dmaqueue *dma_q)
}
}
if (bc != 1)
dprintk(1,"%s: %d buffers handled (should be 1)\n",__FUNCTION__,bc);
dprintk(1, "%s: %d buffers handled (should be 1)\n",
__FUNCTION__, bc);
}
static void vivi_sleep(struct vivi_dmaqueue *dma_q)
@@ -433,13 +434,21 @@ static void vivi_sleep(struct vivi_dmaqueue *dma_q)
dma_q->frame++;
/* Calculate time to wake up */
timeout=dma_q->ini_jiffies+msecs_to_jiffies((dma_q->frame*WAKE_NUMERATOR*1000)/WAKE_DENOMINATOR)-jiffies;
timeout = dma_q->ini_jiffies+
msecs_to_jiffies((dma_q->frame*WAKE_NUMERATOR * 1000)
/ WAKE_DENOMINATOR) - jiffies;
if (timeout <= 0) {
int old = dma_q->frame;
dma_q->frame=(jiffies_to_msecs(jiffies-dma_q->ini_jiffies)*WAKE_DENOMINATOR)/(WAKE_NUMERATOR*1000)+1;
dma_q->frame = (jiffies_to_msecs(jiffies -
dma_q->ini_jiffies) *
WAKE_DENOMINATOR) /
(WAKE_NUMERATOR * 1000) + 1;
timeout=dma_q->ini_jiffies+msecs_to_jiffies((dma_q->frame*WAKE_NUMERATOR*1000)/WAKE_DENOMINATOR)-jiffies;
timeout = dma_q->ini_jiffies+
msecs_to_jiffies((dma_q->frame *
WAKE_NUMERATOR * 1000)
/ WAKE_DENOMINATOR) - jiffies;
dprintk(1, "underrun, losed %d frames. "
"Now, frame is %d. Waking on %d jiffies\n",
@@ -512,13 +521,13 @@ static int restart_video_queue(struct vivi_dmaqueue *dma_q)
dprintk(1, "%s dma_q=0x%08lx\n", __FUNCTION__, (unsigned long)dma_q);
if (!list_empty(&dma_q->active)) {
buf = list_entry(dma_q->active.next, struct vivi_buffer, vb.queue);
buf = list_entry(dma_q->active.next,
struct vivi_buffer, vb.queue);
dprintk(2, "restart_queue [%p/%d]: restart dma\n",
buf, buf->vb.i);
dprintk(1, "Restarting video dma\n");
vivi_stop_thread(dma_q);
// vivi_start_thread(dma_q);
/* cancel all outstanding capture / vbi requests */
list_for_each_entry_safe(buf, prev, &dma_q->active, vb.queue) {
@@ -535,7 +544,8 @@ static int restart_video_queue(struct vivi_dmaqueue *dma_q)
for (;;) {
if (list_empty(&dma_q->queued))
return 0;
buf = list_entry(dma_q->queued.next, struct vivi_buffer, vb.queue);
buf = list_entry(dma_q->queued.next,
struct vivi_buffer, vb.queue);
if (NULL == prev) {
list_del(&buf->vb.queue);
list_add_tail(&buf->vb.queue, &dma_q->active);
@@ -571,11 +581,12 @@ static void vivi_vid_timeout(unsigned long data)
struct vivi_buffer *buf;
while (!list_empty(&vidq->active)) {
buf = list_entry(vidq->active.next, struct vivi_buffer, vb.queue);
buf = list_entry(vidq->active.next,
struct vivi_buffer, vb.queue);
list_del(&buf->vb.queue);
buf->vb.state = VIDEOBUF_ERROR;
wake_up(&buf->vb.done);
printk("vivi/0: [%p/%d] timeout\n", buf, buf->vb.i);
printk(KERN_INFO "vivi/0: [%p/%d] timeout\n", buf, buf->vb.i);
}
restart_video_queue(vidq);
@@ -646,7 +657,8 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
}
if (VIDEOBUF_NEEDS_INIT == buf->vb.state) {
if (0 != (rc = videobuf_iolock(vq,&buf->vb,NULL)))
rc = videobuf_iolock(vq, &buf->vb, NULL);
if (rc < 0)
goto fail;
}
@@ -669,7 +681,8 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
struct vivi_buffer *prev;
if (!list_empty(&vidq->queued)) {
dprintk(1,"adding vb queue=0x%08lx\n",(unsigned long)&buf->vb.queue);
dprintk(1, "adding vb queue=0x%08lx\n",
(unsigned long)&buf->vb.queue);
list_add_tail(&buf->vb.queue, &vidq->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n",
@@ -684,7 +697,8 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
vivi_start_thread(vidq);
} else {
prev = list_entry(vidq->active.prev, struct vivi_buffer, vb.queue);
prev = list_entry(vidq->active.prev,
struct vivi_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
@@ -702,7 +716,8 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
}
}
static void buffer_release(struct videobuf_queue *vq, struct videobuf_buffer *vb)
static void buffer_release(struct videobuf_queue *vq,
struct videobuf_buffer *vb)
{
struct vivi_buffer *buf = container_of(vb, struct vivi_buffer, vb);
struct vivi_fh *fh = vq->priv_data;
@@ -828,7 +843,8 @@ static int vidioc_s_fmt_cap (struct file *file, void *priv,
return (0);
}
static int vidioc_reqbufs (struct file *file, void *priv, struct v4l2_requestbuffers *p)
static int vidioc_reqbufs(struct file *file, void *priv,
struct v4l2_requestbuffers *p)
{
struct vivi_fh *fh = priv;
@@ -959,10 +975,8 @@ static int vidioc_s_ctrl (struct file *file, void *priv,
for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
if (ctrl->id == vivi_qctrl[i].id) {
if (ctrl->value <
vivi_qctrl[i].minimum
|| ctrl->value >
vivi_qctrl[i].maximum) {
if (ctrl->value < vivi_qctrl[i].minimum
|| ctrl->value > vivi_qctrl[i].maximum) {
return (-ERANGE);
}
qctl_regs[i] = ctrl->value;
@@ -990,10 +1004,8 @@ static int vivi_open(struct inode *inode, struct file *file)
if (dev->vfd->minor == minor)
goto found;
return -ENODEV;
found:
/* If more than one user, mutex should be added */
dev->users++;
@@ -1019,24 +1031,18 @@ found:
for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
qctl_regs[i] = vivi_qctrl[i].default_value;
dprintk(1,"Open: fh=0x%08lx, dev=0x%08lx, dev->vidq=0x%08lx\n",
(unsigned long)fh,(unsigned long)dev,(unsigned long)&dev->vidq);
dprintk(1,"Open: list_empty queued=%d\n",list_empty(&dev->vidq.queued));
dprintk(1,"Open: list_empty active=%d\n",list_empty(&dev->vidq.active));
/* Resets frame counters */
dev->h = 0;
dev->m = 0;
dev->s = 0;
dev->us = 0;
dev->mv_count = 0;
dev->jiffies = jiffies;
sprintf(dev->timestr, "%02d:%02d:%02d:%03d",
dev->h, dev->m, dev->s, (dev->us + 500) / 1000);
videobuf_queue_vmalloc_init(&fh->vb_vidq, &vivi_video_qops,
NULL, NULL,
fh->type,
V4L2_FIELD_INTERLACED,
NULL, NULL, fh->type, V4L2_FIELD_INTERLACED,
sizeof(struct vivi_buffer), fh);
return 0;
@@ -1084,7 +1090,7 @@ static int vivi_close(struct inode *inode, struct file *file)
dev->users--;
printk(KERN_DEBUG "vivi: close called (minor=%d, users=%d)\n",minor,dev->users);
dprintk(1, "close called (minor=%d, users=%d)\n", minor, dev->users);
return 0;
}
@@ -1110,8 +1116,7 @@ static int vivi_release(void)
return 0;
}
static int
vivi_mmap(struct file *file, struct vm_area_struct * vma)
static int vivi_mmap(struct file *file, struct vm_area_struct *vma)
{
struct vivi_fh *fh = file->private_data;
int ret;