Commit bb4afaab authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] zoran: more cleanups

From: Ronald Bultje <rbultje@ronald.bitfreak.net>

This patch adds some newlines between variable declarations and function
bodies. This was done on request by Francois Romieu.
parent d9a800f7
......@@ -104,6 +104,7 @@ adv7170_write (struct i2c_client *client,
u8 value)
{
struct adv7170 *encoder = i2c_get_clientdata(client);
encoder->reg[reg] = value;
return i2c_smbus_write_byte_data(client, reg, value);
}
......@@ -130,6 +131,7 @@ adv7170_write_block (struct i2c_client *client,
struct adv7170 *encoder = i2c_get_clientdata(client);
struct i2c_msg msg;
u8 block_data[32];
msg.addr = client->addr;
msg.flags = client->flags;
while (len >= 2) {
......@@ -143,16 +145,16 @@ adv7170_write_block (struct i2c_client *client,
data += 2;
} while (len >= 2 && data[0] == reg &&
msg.len < 32);
if ((ret =
i2c_transfer(client->adapter, &msg, 1)) < 0)
if ((ret = i2c_transfer(client->adapter,
&msg, 1)) < 0)
break;
}
} else {
/* do some slow I2C emulation kind of thing */
while (len >= 2) {
reg = *data++;
if ((ret =
adv7170_write(client, reg, *data++)) < 0)
if ((ret = adv7170_write(client, reg,
*data++)) < 0)
break;
len -= 2;
}
......
......@@ -100,6 +100,7 @@ adv7175_write (struct i2c_client *client,
u8 value)
{
struct adv7175 *encoder = i2c_get_clientdata(client);
encoder->reg[reg] = value;
return i2c_smbus_write_byte_data(client, reg, value);
}
......@@ -126,6 +127,7 @@ adv7175_write_block (struct i2c_client *client,
struct adv7175 *encoder = i2c_get_clientdata(client);
struct i2c_msg msg;
u8 block_data[32];
msg.addr = client->addr;
msg.flags = client->flags;
while (len >= 2) {
......@@ -139,16 +141,16 @@ adv7175_write_block (struct i2c_client *client,
data += 2;
} while (len >= 2 && data[0] == reg &&
msg.len < 32);
if ((ret =
i2c_transfer(client->adapter, &msg, 1)) < 0)
if ((ret = i2c_transfer(client->adapter,
&msg, 1)) < 0)
break;
}
} else {
/* do some slow I2C emulation kind of thing */
while (len >= 2) {
reg = *data++;
if ((ret =
adv7175_write(client, reg, *data++)) < 0)
if ((ret = adv7175_write(client, reg,
*data++)) < 0)
break;
len -= 2;
}
......@@ -163,6 +165,7 @@ dump (struct i2c_client *client)
{
struct adv7175 *encoder = i2c_get_clientdata(client);
int i, j;
printk(KERN_INFO "%s: registry dump\n", I2C_NAME(client));
for (i = 0; i < 182 / 8; i++) {
printk("%s: 0x%02x -", I2C_NAME(client), i * 8);
......
......@@ -113,6 +113,7 @@ bt819_write (struct i2c_client *client,
u8 value)
{
struct bt819 *decoder = i2c_get_clientdata(client);
decoder->reg[reg] = value;
return i2c_smbus_write_byte_data(client, reg, value);
}
......@@ -124,6 +125,7 @@ bt819_setbit (struct i2c_client *client,
u8 value)
{
struct bt819 *decoder = i2c_get_clientdata(client);
return bt819_write(client, reg,
(decoder->
reg[reg] & ~(1 << bit)) |
......@@ -145,6 +147,7 @@ bt819_write_block (struct i2c_client *client,
struct bt819 *decoder = i2c_get_clientdata(client);
struct i2c_msg msg;
u8 block_data[32];
msg.addr = client->addr;
msg.flags = client->flags;
while (len >= 2) {
......@@ -158,8 +161,8 @@ bt819_write_block (struct i2c_client *client,
data += 2;
} while (len >= 2 && data[0] == reg &&
msg.len < 32);
if ((ret =
i2c_transfer(client->adapter, &msg, 1)) < 0)
if ((ret = i2c_transfer(client->adapter,
&msg, 1)) < 0)
break;
}
} else {
......
......@@ -98,6 +98,7 @@ bt856_write (struct i2c_client *client,
u8 value)
{
struct bt856 *encoder = i2c_get_clientdata(client);
encoder->reg[reg - REG_OFFSET] = value;
return i2c_smbus_write_byte_data(client, reg, value);
}
......@@ -109,6 +110,7 @@ bt856_setbit (struct i2c_client *client,
u8 value)
{
struct bt856 *encoder = i2c_get_clientdata(client);
return bt856_write(client, reg,
(encoder->
reg[reg - REG_OFFSET] & ~(1 << bit)) |
......@@ -120,6 +122,7 @@ bt856_dump (struct i2c_client *client)
{
int i;
struct bt856 *encoder = i2c_get_clientdata(client);
printk(KERN_INFO "%s: register dump:", I2C_NAME(client));
for (i = 0xd6; i <= 0xde; i += 2)
printk(" %02x", encoder->reg[i - REG_OFFSET]);
......
......@@ -86,6 +86,7 @@ saa7110_write (struct i2c_client *client,
u8 value)
{
struct saa7110 *decoder = i2c_get_clientdata(client);
decoder->reg[reg] = value;
return i2c_smbus_write_byte_data(client, reg, value);
}
......@@ -97,6 +98,7 @@ saa7110_write_block (struct i2c_client *client,
{
int ret = -1;
u8 reg = *data++;
len--;
/* the saa7110 has an autoincrement function, use it if
......@@ -105,6 +107,7 @@ saa7110_write_block (struct i2c_client *client,
struct saa7110 *decoder = i2c_get_clientdata(client);
struct i2c_msg msg;
u8 block_data[54];
msg.len = 0;
msg.buf = (char *) block_data;
msg.addr = client->addr;
......@@ -119,8 +122,8 @@ saa7110_write_block (struct i2c_client *client,
}
} else {
while (len-- >= 1) {
if ((ret =
saa7110_write(client, reg++, *data++)) < 0)
if ((ret = saa7110_write(client, reg++,
*data++)) < 0)
break;
}
}
......@@ -279,6 +282,7 @@ saa7110_command (struct i2c_client *client,
case DECODER_GET_CAPABILITIES:
{
struct video_decoder_capability *dc = arg;
dc->flags =
VIDEO_DECODER_PAL | VIDEO_DECODER_NTSC |
VIDEO_DECODER_SECAM | VIDEO_DECODER_AUTO;
......
......@@ -93,6 +93,7 @@ saa7111_write (struct i2c_client *client,
u8 value)
{
struct saa7111 *decoder = i2c_get_clientdata(client);
decoder->reg[reg] = value;
return i2c_smbus_write_byte_data(client, reg, value);
}
......@@ -112,6 +113,7 @@ saa7111_write_block (struct i2c_client *client,
struct saa7111 *decoder = i2c_get_clientdata(client);
struct i2c_msg msg;
u8 block_data[32];
msg.addr = client->addr;
msg.flags = client->flags;
while (len >= 2) {
......@@ -125,16 +127,16 @@ saa7111_write_block (struct i2c_client *client,
data += 2;
} while (len >= 2 && data[0] == reg &&
msg.len < 32);
if ((ret =
i2c_transfer(client->adapter, &msg, 1)) < 0)
if ((ret = i2c_transfer(client->adapter,
&msg, 1)) < 0)
break;
}
} else {
/* do some slow I2C emulation kind of thing */
while (len >= 2) {
reg = *data++;
if ((ret =
saa7111_write(client, reg, *data++)) < 0)
if ((ret = saa7111_write(client, reg,
*data++)) < 0)
break;
len -= 2;
}
......
......@@ -144,6 +144,7 @@ saa7114_write (struct i2c_client *client,
u8 value)
{
/*struct saa7114 *decoder = i2c_get_clientdata(client);*/
/*decoder->reg[reg] = value;*/
return i2c_smbus_write_byte_data(client, reg, value);
}
......@@ -163,6 +164,7 @@ saa7114_write_block (struct i2c_client *client,
/*struct saa7114 *decoder = i2c_get_clientdata(client);*/
struct i2c_msg msg;
u8 block_data[32];
msg.addr = client->addr;
msg.flags = client->flags;
while (len >= 2) {
......@@ -176,16 +178,16 @@ saa7114_write_block (struct i2c_client *client,
data += 2;
} while (len >= 2 && data[0] == reg &&
msg.len < 32);
if ((ret =
i2c_transfer(client->adapter, &msg, 1)) < 0)
if ((ret = i2c_transfer(client->adapter,
&msg, 1)) < 0)
break;
}
} else {
/* do some slow I2C emulation kind of thing */
while (len >= 2) {
reg = *data++;
if ((ret =
saa7114_write(client, reg, *data++)) < 0)
if ((ret = saa7114_write(client, reg,
*data++)) < 0)
break;
len -= 2;
}
......
......@@ -98,6 +98,7 @@ saa7185_write (struct i2c_client *client,
u8 value)
{
struct saa7185 *encoder = i2c_get_clientdata(client);
dprintk(1, KERN_DEBUG "SAA7185: %02x set to %02x\n", reg, value);
encoder->reg[reg] = value;
return i2c_smbus_write_byte_data(client, reg, value);
......@@ -118,6 +119,7 @@ saa7185_write_block (struct i2c_client *client,
struct saa7185 *encoder = i2c_get_clientdata(client);
struct i2c_msg msg;
u8 block_data[32];
msg.addr = client->addr;
msg.flags = client->flags;
while (len >= 2) {
......@@ -131,16 +133,16 @@ saa7185_write_block (struct i2c_client *client,
data += 2;
} while (len >= 2 && data[0] == reg &&
msg.len < 32);
if ((ret =
i2c_transfer(client->adapter, &msg, 1)) < 0)
if ((ret = i2c_transfer(client->adapter,
&msg, 1)) < 0)
break;
}
} else {
/* do some slow I2C emulation kind of thing */
while (len >= 2) {
reg = *data++;
if ((ret =
saa7185_write(client, reg, *data++)) < 0)
if ((ret = saa7185_write(client, reg,
*data++)) < 0)
break;
len -= 2;
}
......
......@@ -76,6 +76,7 @@ vpx3220_write (struct i2c_client *client,
u8 value)
{
struct vpx3220 *decoder = i2c_get_clientdata(client);
decoder->reg[reg] = value;
return i2c_smbus_write_byte_data(client, reg, value);
}
......@@ -294,6 +295,7 @@ vpx3220_dump_i2c (struct i2c_client *client)
{
int len = sizeof(init_common);
const unsigned char *data = init_common;
while (len > 1) {
dprintk(1,
KERN_DEBUG "vpx3216b i2c reg 0x%02x data 0x%02x\n",
......
......@@ -624,6 +624,7 @@ static int
zoran_i2c_getsda (void *data)
{
struct zoran *zr = (struct zoran *) data;
return (btread(ZR36057_I2CBR) >> 1) & 1;
}
......@@ -631,6 +632,7 @@ static int
zoran_i2c_getscl (void *data)
{
struct zoran *zr = (struct zoran *) data;
return btread(ZR36057_I2CBR) & 1;
}
......@@ -639,6 +641,7 @@ zoran_i2c_setsda (void *data,
int state)
{
struct zoran *zr = (struct zoran *) data;
if (state)
zr->i2cbr |= 2;
else
......@@ -651,6 +654,7 @@ zoran_i2c_setscl (void *data,
int state)
{
struct zoran *zr = (struct zoran *) data;
if (state)
zr->i2cbr |= 1;
else
......@@ -767,6 +771,7 @@ zoran_check_jpg_settings (struct zoran *zr,
struct zoran_jpg_settings *settings)
{
int err = 0, err0 = 0;
dprintk(4,
KERN_DEBUG
"%s: check_jpg_settings() - dec: %d, Hdcm: %d, Vdcm: %d, Tdcm: %d\n",
......@@ -1223,6 +1228,7 @@ find_zr36057 (void)
} else {
int i;
unsigned short ss_vendor, ss_device;
ss_vendor = zr->pci_dev->subsystem_vendor;
ss_device = zr->pci_dev->subsystem_device;
dprintk(1,
......@@ -1483,6 +1489,7 @@ static int __init
init_dc10_cards (void)
{
int i;
memset(zoran, 0, sizeof(zoran));
printk(KERN_INFO "Zoran MJPEG board driver version %d.%d.%d\n",
MAJOR_VERSION, MINOR_VERSION, RELEASE_VERSION);
......@@ -1539,6 +1546,7 @@ init_dc10_cards (void)
/* take care of Natoma chipset and a revision 1 zr36057 */
for (i = 0; i < zoran_num; i++) {
struct zoran *zr = &zoran[i];
if (pci_pci_problems & PCIPCI_NATOMA && zr->revision <= 1) {
zr->jpg_buffers.need_contiguous = 1;
dprintk(1,
......@@ -1562,6 +1570,7 @@ static void __exit
unload_dc10_cards (void)
{
int i;
for (i = 0; i < zoran_num; i++)
zoran_release(&zoran[i]);
}
......
......@@ -190,6 +190,7 @@ static inline unsigned long
get_time (void)
{
struct timeval tv;
do_gettimeofday(&tv);
return (1000000 * tv.tv_sec + tv.tv_usec);
}
......@@ -868,8 +869,8 @@ zr36057_set_jpg (struct zoran *zr,
void
print_interrupts (struct zoran *zr)
{
int res, noerr;
noerr = 0;
int res, noerr = 0;
printk(KERN_INFO "%s: interrupts received:", ZR_DEVNAME(zr));
if ((res = zr->field_counter) < -1 || res > 1) {
printk(" FD:%d", res);
......@@ -931,6 +932,7 @@ static u32
count_reset_interrupt (struct zoran *zr)
{
u32 isr;
if ((isr = btread(ZR36057_ISR) & 0x78000000)) {
if (isr & ZR36057_ISR_GIRQ1) {
btwrite(ZR36057_ISR_GIRQ1, ZR36057_ISR);
......@@ -961,6 +963,7 @@ void
jpeg_start (struct zoran *zr)
{
int reg;
zr->frame_num = 0;
/* deassert P_reset, disable code transfer, deassert Active */
......@@ -1625,10 +1628,11 @@ void
zoran_set_pci_master (struct zoran *zr,
int set_master)
{
u16 command;
if (set_master) {
pci_set_master(zr->pci_dev);
} else {
u16 command;
pci_read_config_word(zr->pci_dev, PCI_COMMAND, &command);
command &= ~PCI_COMMAND_MASTER;
pci_write_config_word(zr->pci_dev, PCI_COMMAND, command);
......@@ -1639,6 +1643,7 @@ void
zoran_init_hardware (struct zoran *zr)
{
int j, zero = 0;
/* Enable bus-mastering */
zoran_set_pci_master(zr, 1);
......@@ -1700,6 +1705,7 @@ void
zr36057_init_vfe (struct zoran *zr)
{
u32 reg;
reg = btread(ZR36057_VFESPFR);
reg |= ZR36057_VFESPFR_LittleEndian;
reg &= ~ZR36057_VFESPFR_VCLKPol;
......@@ -1730,6 +1736,7 @@ decoder_command (struct zoran *zr,
if (zr->card.type == LML33 &&
(cmd == DECODER_SET_NORM || DECODER_SET_INPUT)) {
int res;
// Bt819 needs to reset its FIFO buffer using #FRST pin and
// LML33 card uses GPIO(7) for that.
GPIO(zr, 7, 0);
......
......@@ -51,6 +51,7 @@
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/pci.h>
#include <linux/vmalloc.h>
#include <linux/interrupt.h>
#include <linux/i2c.h>
......@@ -370,6 +371,7 @@ v4l_fbuffer_alloc (struct file *file)
int n =
(fh->v4l_buffers.buffer_size + PAGE_SIZE -
1) / PAGE_SIZE;
mem =
(unsigned char *) bigphysarea_alloc_pages(n, 0,
GFP_KERNEL);
......@@ -412,6 +414,7 @@ v4l_fbuffer_alloc (struct file *file)
int size =
fh->v4l_buffers.num_buffers *
fh->v4l_buffers.buffer_size;
pmem = get_high_mem(size);
if (pmem == 0) {
dprintk(1,
......@@ -847,9 +850,10 @@ v4l_grab (struct file *file,
if (res)
return res;
}
if ((res =
zoran_v4l_set_format(file, mp->width, mp->height,
&zoran_formats[i])))
if ((res = zoran_v4l_set_format(file,
mp->width,
mp->height,
&zoran_formats[i])))
return res;
zr->v4l_settings = fh->v4l_settings;
......@@ -2032,6 +2036,7 @@ zoran_do_ioctl (struct inode *inode,
case VIDIOCGCAP:
{
struct video_capability *vcap = arg;
dprintk(3, KERN_DEBUG "%s: VIDIOCGCAP\n", ZR_DEVNAME(zr));
memset(vcap, 0, sizeof(struct video_capability));
......@@ -2154,6 +2159,7 @@ zoran_do_ioctl (struct inode *inode,
for (i = 0; i < zoran_num_formats; i++) {
const struct zoran_format *fmt = &zoran_formats[i];
if (fmt->palette != -1 &&
fmt->flags & ZORAN_FORMAT_OVERLAY &&
fmt->palette == vpict->palette &&
......@@ -2203,7 +2209,9 @@ zoran_do_ioctl (struct inode *inode,
case VIDIOCGWIN:
{
struct video_window *vwin = arg;
dprintk(3, KERN_DEBUG "%s: VIDIOCGWIN\n", ZR_DEVNAME(zr));
memset(vwin, 0, sizeof(struct video_window));
down(&zr->resource_lock);
vwin->x = fh->overlay_settings.x;
......@@ -2241,7 +2249,9 @@ zoran_do_ioctl (struct inode *inode,
case VIDIOCGFBUF:
{
struct video_buffer *vbuf = arg;
dprintk(3, KERN_DEBUG "%s: VIDIOCGFBUF\n", ZR_DEVNAME(zr));
down(&zr->resource_lock);
*vbuf = zr->buffer;
up(&zr->resource_lock);
......@@ -2285,8 +2295,10 @@ zoran_do_ioctl (struct inode *inode,
case VIDIOCSYNC:
{
int *frame = arg, res;
dprintk(3, KERN_DEBUG "%s: VIDIOCSYNC - frame=%d\n",
ZR_DEVNAME(zr), *frame);
down(&zr->resource_lock);
res = v4l_sync(file, *frame);
up(&zr->resource_lock);
......@@ -2300,11 +2312,13 @@ zoran_do_ioctl (struct inode *inode,
{
struct video_mmap *vmap = arg;
int res;
dprintk(3,
KERN_DEBUG
"%s: VIDIOCMCAPTURE - frame=%d, geom=%dx%d, fmt=%d\n",
ZR_DEVNAME(zr), vmap->frame, vmap->width, vmap->height,
vmap->format);
down(&zr->resource_lock);
res = v4l_grab(file, vmap);
up(&zr->resource_lock);
......@@ -2358,6 +2372,7 @@ zoran_do_ioctl (struct inode *inode,
struct video_unit *vunit = arg;
dprintk(3, KERN_DEBUG "%s: VIDIOCGUNIT\n", ZR_DEVNAME(zr));
vunit->video = zr->video_dev->minor;
vunit->vbi = VIDEO_NO_UNIT;
vunit->radio = VIDEO_NO_UNIT;
......@@ -2393,6 +2408,7 @@ zoran_do_ioctl (struct inode *inode,
case BUZIOC_G_PARAMS:
{
struct zoran_params *bparams = arg;
dprintk(3, KERN_DEBUG "%s: BUZIOC_G_PARAMS\n", ZR_DEVNAME(zr));
memset(bparams, 0, sizeof(struct zoran_params));
......@@ -2686,6 +2702,7 @@ zoran_do_ioctl (struct inode *inode,
struct v4l2_fmtdesc *fmt = arg;
int index = fmt->index, num = -1, i, flag = 0, type =
fmt->type;
dprintk(3, KERN_DEBUG "%s: VIDIOC_ENUM_FMT - index=%d\n",
ZR_DEVNAME(zr), fmt->index);
......@@ -3530,6 +3547,7 @@ zoran_do_ioctl (struct inode *inode,
case VIDIOC_QUERYCTRL:
{
struct v4l2_queryctrl *ctrl = arg;
dprintk(3, KERN_DEBUG "%s: VIDIOC_QUERYCTRL - id=%d\n",
ZR_DEVNAME(zr), ctrl->id);
......@@ -3571,6 +3589,7 @@ zoran_do_ioctl (struct inode *inode,
case VIDIOC_G_CTRL:
{
struct v4l2_control *ctrl = arg;
dprintk(3, KERN_DEBUG "%s: VIDIOC_G_CTRL - id=%d\n",
ZR_DEVNAME(zr), ctrl->id);
......@@ -3652,6 +3671,7 @@ zoran_do_ioctl (struct inode *inode,
case VIDIOC_ENUMSTD:
{
struct v4l2_standard *std = arg;
dprintk(3, KERN_DEBUG "%s: VIDIOC_ENUMSTD - index=%d\n",
ZR_DEVNAME(zr), std->index);
......@@ -3707,6 +3727,7 @@ zoran_do_ioctl (struct inode *inode,
{
v4l2_std_id *std = arg;
int norm;
dprintk(3, KERN_DEBUG "%s: VIDIOC_G_STD\n", ZR_DEVNAME(zr));
down(&zr->resource_lock);
......@@ -3804,6 +3825,7 @@ zoran_do_ioctl (struct inode *inode,
case VIDIOC_G_INPUT:
{
int *input = arg;
dprintk(3, KERN_DEBUG "%s: VIDIOC_G_INPUT\n", ZR_DEVNAME(zr));
down(&zr->resource_lock);
......@@ -3817,6 +3839,7 @@ zoran_do_ioctl (struct inode *inode,
case VIDIOC_S_INPUT:
{
int *input = arg, res = 0;
dprintk(3, KERN_DEBUG "%s: VIDIOC_S_INPUT - input=%d\n",
ZR_DEVNAME(zr), *input);
......@@ -3835,6 +3858,7 @@ zoran_do_ioctl (struct inode *inode,
case VIDIOC_ENUMOUTPUT:
{
struct v4l2_output *outp = arg;
dprintk(3, KERN_DEBUG "%s: VIDIOC_ENUMOUTPUT - index=%d\n",
ZR_DEVNAME(zr), outp->index);
......@@ -4005,7 +4029,9 @@ zoran_do_ioctl (struct inode *inode,
case VIDIOC_G_JPEGCOMP:
{
struct v4l2_jpegcompression *params = arg;
dprintk(3, KERN_DEBUG "%s: VIDIOC_G_JPEGCOMP\n", ZR_DEVNAME(zr));
dprintk(3, KERN_DEBUG "%s: VIDIOC_G_JPEGCOMP\n",
ZR_DEVNAME(zr));
memset(params, 0, sizeof(*params));
......@@ -4175,6 +4201,7 @@ zoran_do_ioctl (struct inode *inode,
} else if (fmt->type ==
V4L2_BUF_TYPE_VIDEO_CAPTURE) {
int i;
for (i = 0; i < zoran_num_formats; i++)
if (zoran_formats[i].fourcc ==
fmt->fmt.pix.pixelformat)
......@@ -4321,6 +4348,7 @@ static void
zoran_vm_open (struct vm_area_struct *vma)
{
struct zoran_mapping *map = vma->vm_private_data;
map->count++;
}
......
......@@ -248,6 +248,7 @@ zoran_proc_init (struct zoran *zr)
{
#ifdef CONFIG_PROC_FS
char name[8];
snprintf(name, 7, "zoran%d", zr->id);
if ((zr->zoran_proc = create_proc_entry(name, 0, 0))) {
zr->zoran_proc->read_proc = zoran_read_proc;
......@@ -272,6 +273,7 @@ zoran_proc_cleanup (struct zoran *zr)
{
#ifdef CONFIG_PROC_FS
char name[8];
snprintf(name, 7, "zoran%d", zr->id);
if (zr->zoran_proc) {
remove_proc_entry(name, 0);
......
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