Commit 58159171 authored by Frank Schaefer's avatar Frank Schaefer Committed by Mauro Carvalho Chehab

[media] em28xx: move progressive/interlaced fields from struct em28xx to struct v4l2

The video progressive data fields belong to analog TV. Move them out
of the common em28xx struct.
Signed-off-by: default avatarFrank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 06e20672
...@@ -2707,8 +2707,6 @@ static void em28xx_card_setup(struct em28xx *dev) ...@@ -2707,8 +2707,6 @@ static void em28xx_card_setup(struct em28xx *dev)
if (dev->board.is_webcam) { if (dev->board.is_webcam) {
if (em28xx_detect_sensor(dev) < 0) if (em28xx_detect_sensor(dev) < 0)
dev->board.is_webcam = 0; dev->board.is_webcam = 0;
else
dev->progressive = 1;
} }
switch (dev->model) { switch (dev->model) {
......
...@@ -447,9 +447,10 @@ static void em28xx_copy_video(struct em28xx *dev, ...@@ -447,9 +447,10 @@ static void em28xx_copy_video(struct em28xx *dev,
unsigned char *usb_buf, unsigned char *usb_buf,
unsigned long len) unsigned long len)
{ {
struct em28xx_v4l2 *v4l2 = dev->v4l2;
void *fieldstart, *startwrite, *startread; void *fieldstart, *startwrite, *startread;
int linesdone, currlinedone, offset, lencopy, remain; int linesdone, currlinedone, offset, lencopy, remain;
int bytesperline = dev->v4l2->width << 1; int bytesperline = v4l2->width << 1;
if (buf->pos + len > buf->length) if (buf->pos + len > buf->length)
len = buf->length - buf->pos; len = buf->length - buf->pos;
...@@ -457,7 +458,7 @@ static void em28xx_copy_video(struct em28xx *dev, ...@@ -457,7 +458,7 @@ static void em28xx_copy_video(struct em28xx *dev,
startread = usb_buf; startread = usb_buf;
remain = len; remain = len;
if (dev->progressive || buf->top_field) if (v4l2->progressive || buf->top_field)
fieldstart = buf->vb_buf; fieldstart = buf->vb_buf;
else /* interlaced mode, even nr. of lines */ else /* interlaced mode, even nr. of lines */
fieldstart = buf->vb_buf + bytesperline; fieldstart = buf->vb_buf + bytesperline;
...@@ -465,7 +466,7 @@ static void em28xx_copy_video(struct em28xx *dev, ...@@ -465,7 +466,7 @@ static void em28xx_copy_video(struct em28xx *dev,
linesdone = buf->pos / bytesperline; linesdone = buf->pos / bytesperline;
currlinedone = buf->pos % bytesperline; currlinedone = buf->pos % bytesperline;
if (dev->progressive) if (v4l2->progressive)
offset = linesdone * bytesperline + currlinedone; offset = linesdone * bytesperline + currlinedone;
else else
offset = linesdone * bytesperline * 2 + currlinedone; offset = linesdone * bytesperline * 2 + currlinedone;
...@@ -489,7 +490,7 @@ static void em28xx_copy_video(struct em28xx *dev, ...@@ -489,7 +490,7 @@ static void em28xx_copy_video(struct em28xx *dev,
remain -= lencopy; remain -= lencopy;
while (remain > 0) { while (remain > 0) {
if (dev->progressive) if (v4l2->progressive)
startwrite += lencopy; startwrite += lencopy;
else else
startwrite += lencopy + bytesperline; startwrite += lencopy + bytesperline;
...@@ -611,7 +612,9 @@ finish_field_prepare_next(struct em28xx *dev, ...@@ -611,7 +612,9 @@ finish_field_prepare_next(struct em28xx *dev,
struct em28xx_buffer *buf, struct em28xx_buffer *buf,
struct em28xx_dmaqueue *dma_q) struct em28xx_dmaqueue *dma_q)
{ {
if (dev->progressive || dev->top_field) { /* Brand new frame */ struct em28xx_v4l2 *v4l2 = dev->v4l2;
if (v4l2->progressive || dev->top_field) { /* Brand new frame */
if (buf != NULL) if (buf != NULL)
finish_buffer(dev, buf); finish_buffer(dev, buf);
buf = get_next_buf(dev, dma_q); buf = get_next_buf(dev, dma_q);
...@@ -1230,10 +1233,10 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, ...@@ -1230,10 +1233,10 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
/* FIXME: TOP? NONE? BOTTOM? ALTENATE? */ /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */
if (dev->progressive) if (v4l2->progressive)
f->fmt.pix.field = V4L2_FIELD_NONE; f->fmt.pix.field = V4L2_FIELD_NONE;
else else
f->fmt.pix.field = dev->interlaced ? f->fmt.pix.field = v4l2->interlaced_fieldmode ?
V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP; V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP;
return 0; return 0;
} }
...@@ -1254,6 +1257,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, ...@@ -1254,6 +1257,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
{ {
struct em28xx_fh *fh = priv; struct em28xx_fh *fh = priv;
struct em28xx *dev = fh->dev; struct em28xx *dev = fh->dev;
struct em28xx_v4l2 *v4l2 = dev->v4l2;
unsigned int width = f->fmt.pix.width; unsigned int width = f->fmt.pix.width;
unsigned int height = f->fmt.pix.height; unsigned int height = f->fmt.pix.height;
unsigned int maxw = norm_maxw(dev); unsigned int maxw = norm_maxw(dev);
...@@ -1295,10 +1299,10 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, ...@@ -1295,10 +1299,10 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
f->fmt.pix.bytesperline = (width * fmt->depth + 7) >> 3; f->fmt.pix.bytesperline = (width * fmt->depth + 7) >> 3;
f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * height; f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * height;
f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
if (dev->progressive) if (v4l2->progressive)
f->fmt.pix.field = V4L2_FIELD_NONE; f->fmt.pix.field = V4L2_FIELD_NONE;
else else
f->fmt.pix.field = dev->interlaced ? f->fmt.pix.field = v4l2->interlaced_fieldmode ?
V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP; V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP;
f->fmt.pix.priv = 0; f->fmt.pix.priv = 0;
...@@ -2312,6 +2316,9 @@ static int em28xx_v4l2_init(struct em28xx *dev) ...@@ -2312,6 +2316,9 @@ static int em28xx_v4l2_init(struct em28xx *dev)
v4l2_ctrl_handler_init(hdl, 8); v4l2_ctrl_handler_init(hdl, 8);
v4l2->v4l2_dev.ctrl_handler = hdl; v4l2->v4l2_dev.ctrl_handler = hdl;
if (dev->board.is_webcam)
v4l2->progressive = 1;
/* /*
* Default format, used for tvp5150 or saa711x output formats * Default format, used for tvp5150 or saa711x output formats
*/ */
...@@ -2426,7 +2433,7 @@ static int em28xx_v4l2_init(struct em28xx *dev) ...@@ -2426,7 +2433,7 @@ static int em28xx_v4l2_init(struct em28xx *dev)
/* set default norm */ /* set default norm */
v4l2->norm = V4L2_STD_PAL; v4l2->norm = V4L2_STD_PAL;
v4l2_device_call_all(&v4l2->v4l2_dev, 0, core, s_std, v4l2->norm); v4l2_device_call_all(&v4l2->v4l2_dev, 0, core, s_std, v4l2->norm);
dev->interlaced = EM28XX_INTERLACED_DEFAULT; v4l2->interlaced_fieldmode = EM28XX_INTERLACED_DEFAULT;
/* Analog specific initialization */ /* Analog specific initialization */
v4l2->format = &format[0]; v4l2->format = &format[0];
......
...@@ -522,6 +522,11 @@ struct em28xx_v4l2 { ...@@ -522,6 +522,11 @@ struct em28xx_v4l2 {
struct em28xx_fmt *format; struct em28xx_fmt *format;
v4l2_std_id norm; /* selected tv norm */ v4l2_std_id norm; /* selected tv norm */
/* Progressive/interlaced mode */
bool progressive;
int interlaced_fieldmode; /* 1=interlaced fields, 0=just top fields */
/* FIXME: everything else than interlaced_fieldmode=1 doesn't work */
/* Frame properties */ /* Frame properties */
int width; /* current frame width */ int width; /* current frame width */
int height; /* current frame height */ int height; /* current frame height */
...@@ -601,9 +606,6 @@ struct em28xx { ...@@ -601,9 +606,6 @@ struct em28xx {
int sensor_xres, sensor_yres; int sensor_xres, sensor_yres;
int sensor_xtal; int sensor_xtal;
/* Progressive (non-interlaced) mode */
int progressive;
/* Controls audio streaming */ /* Controls audio streaming */
struct work_struct wq_trigger; /* Trigger to start/stop audio for alsa module */ struct work_struct wq_trigger; /* Trigger to start/stop audio for alsa module */
atomic_t stream_started; /* stream should be running if true */ atomic_t stream_started; /* stream should be running if true */
...@@ -641,8 +643,6 @@ struct em28xx { ...@@ -641,8 +643,6 @@ struct em28xx {
int mute; int mute;
int volume; int volume;
int interlaced; /* 1=interlace fileds, 0=just top fileds */
unsigned long hash; /* eeprom hash - for boards with generic ID */ unsigned long hash; /* eeprom hash - for boards with generic ID */
unsigned long i2c_hash; /* i2c devicelist hash - unsigned long i2c_hash; /* i2c devicelist hash -
for boards with generic ID */ for boards with generic ID */
......
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