Skip to content

Commit

Permalink
V4L/DVB (7567): em28xx: Some cleanups
Browse files Browse the repository at this point in the history
Removes some fields from data structs.

There are some fields that are just caching some calculus for buffer
size. The calculus were moved to the places it were needed and the now
unused fields were removed.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
  • Loading branch information
Mauro Carvalho Chehab committed Apr 24, 2008
1 parent 59d3448 commit 44dc733
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 41 deletions.
4 changes: 2 additions & 2 deletions drivers/media/video/em28xx/em28xx-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,13 @@ int em28xx_set_alternate(struct em28xx *dev)
{
int errCode, prev_alt = dev->alt;
int i;
unsigned int min_pkt_size = dev->bytesperline + 4;
unsigned int min_pkt_size = dev->width * 2 + 4;

/* When image size is bigger than a certain value,
the frame size should be increased, otherwise, only
green screen will be received.
*/
if (dev->frame_size > 720*240*2)
if (dev->width * 2 * dev->height > 720 * 240 * 2)
min_pkt_size *= 2;

for (i = 0; i < dev->num_alt; i++) {
Expand Down
43 changes: 11 additions & 32 deletions drivers/media/video/em28xx/em28xx-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,7 @@ static void em28xx_copy_video(struct em28xx *dev,
{
void *fieldstart, *startwrite, *startread;
int linesdone, currlinedone, offset, lencopy, remain;

if (dev->frame_size != buf->vb.size) {
em28xx_errdev("size %i and buf.length %lu are different!\n",
dev->frame_size, buf->vb.size);
return;
}
int bytesperline = dev->width << 1;

if (dma_q->pos + len > buf->vb.size)
len = buf->vb.size - dma_q->pos;
Expand All @@ -177,13 +172,13 @@ static void em28xx_copy_video(struct em28xx *dev,
if (buf->top_field)
fieldstart = outp;
else
fieldstart = outp + dev->bytesperline;
fieldstart = outp + bytesperline;

linesdone = dma_q->pos / dev->bytesperline;
currlinedone = dma_q->pos % dev->bytesperline;
offset = linesdone * dev->bytesperline * 2 + currlinedone;
linesdone = dma_q->pos / bytesperline;
currlinedone = dma_q->pos % bytesperline;
offset = linesdone * bytesperline * 2 + currlinedone;
startwrite = fieldstart + offset;
lencopy = dev->bytesperline - currlinedone;
lencopy = bytesperline - currlinedone;
lencopy = lencopy > remain ? remain : lencopy;

if ((char *)startwrite + lencopy > (char *)outp + buf->vb.size) {
Expand All @@ -199,12 +194,12 @@ static void em28xx_copy_video(struct em28xx *dev,
remain -= lencopy;

while (remain > 0) {
startwrite += lencopy + dev->bytesperline;
startwrite += lencopy + bytesperline;
startread += lencopy;
if (dev->bytesperline > remain)
if (bytesperline > remain)
lencopy = remain;
else
lencopy = dev->bytesperline;
lencopy = bytesperline;

if ((char *)startwrite + lencopy > (char *)outp + buf->vb.size) {
em28xx_isocdbg("Overflow of %zi bytes past buffer end (2)\n",
Expand Down Expand Up @@ -617,16 +612,13 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
struct em28xx_dmaqueue *vidq = &dev->vidq;
int rc = 0, urb_init = 0;

/* BUG_ON(NULL == fh->fmt); */

/* FIXME: It assumes depth = 16 */
/* The only currently supported format is 16 bits/pixel */
buf->vb.size = 16 * dev->width * dev->height >> 3;

if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size)
return -EINVAL;

buf->fmt = fh->fmt;
buf->vb.width = dev->width;
buf->vb.height = dev->height;
buf->vb.field = field;
Expand Down Expand Up @@ -877,8 +869,8 @@ static int vidioc_g_fmt_cap(struct file *file, void *priv,
f->fmt.pix.width = dev->width;
f->fmt.pix.height = dev->height;
f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
f->fmt.pix.bytesperline = dev->bytesperline;
f->fmt.pix.sizeimage = dev->frame_size;
f->fmt.pix.bytesperline = dev->width * 2;
f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * dev->height;
f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;

/* FIXME: TOP? NONE? BOTTOM? ALTENATE? */
Expand Down Expand Up @@ -979,9 +971,6 @@ static int vidioc_s_fmt_cap(struct file *file, void *priv,
/* set new image size */
dev->width = f->fmt.pix.width;
dev->height = f->fmt.pix.height;
dev->frame_size = dev->width * dev->height * 2;
dev->field_size = dev->frame_size >> 1;
dev->bytesperline = dev->width * 2;
get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale);

em28xx_set_alternate(dev);
Expand Down Expand Up @@ -1019,9 +1008,6 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm)
/* set new image size */
dev->width = f.fmt.pix.width;
dev->height = f.fmt.pix.height;
dev->frame_size = dev->width * dev->height * 2;
dev->field_size = dev->frame_size >> 1;
dev->bytesperline = dev->width * 2;
get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale);

em28xx_resolution_set(dev);
Expand Down Expand Up @@ -1736,9 +1722,6 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) {
dev->width = norm_maxw(dev);
dev->height = norm_maxh(dev);
dev->frame_size = dev->width * dev->height * 2;
dev->field_size = dev->frame_size >> 1; /*both_fileds ? dev->frame_size>>1 : dev->frame_size; */
dev->bytesperline = dev->width * 2;
dev->hscale = 0;
dev->vscale = 0;

Expand Down Expand Up @@ -2152,10 +2135,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
dev->width = maxw;
dev->height = maxh;
dev->interlaced = EM28XX_INTERLACED_DEFAULT;
dev->field_size = dev->width * dev->height;
dev->frame_size =
dev->interlaced ? dev->field_size << 1 : dev->field_size;
dev->bytesperline = dev->width * 2;
dev->hscale = 0;
dev->vscale = 0;
dev->ctl_input = 2;
Expand Down
7 changes: 0 additions & 7 deletions drivers/media/video/em28xx/em28xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ struct em28xx_buffer {
/* common v4l buffer stuff -- must be first */
struct videobuf_buffer vb;

struct em28xx_fmt *fmt;

struct list_head frame;
int top_field;
int receiving;
Expand Down Expand Up @@ -294,9 +292,6 @@ struct em28xx {
/* frame properties */
int width; /* current frame width */
int height; /* current frame height */
int frame_size; /* current frame size */
int field_size; /* current field size */
int bytesperline;
int hscale; /* horizontal scale factor (see datasheet) */
int vscale; /* vertical scale factor (see datasheet) */
int interlaced; /* 1=interlace fileds, 0=just top fileds */
Expand Down Expand Up @@ -352,9 +347,7 @@ struct em28xx_fh {
unsigned int stream_on:1; /* Locks streams */
int radio;

unsigned int width, height;
struct videobuf_queue vb_vidq;
struct em28xx_fmt *fmt;

enum v4l2_buf_type type;
};
Expand Down

0 comments on commit 44dc733

Please sign in to comment.