Commit 58fc1ce3 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

V4L/DVB (12171): em28xx: fix webcam usage with different output formats

Discovered the bug that were limiting the output format to just RGB565.
Now, it is possible to output image at Bayer format (the original one,
as generated by Silvercrest sensor, and two others), and also on YUY.

Adds Bayer formats also to the driver.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent ed5f1431
...@@ -655,7 +655,6 @@ int em28xx_set_outfmt(struct em28xx *dev) ...@@ -655,7 +655,6 @@ int em28xx_set_outfmt(struct em28xx *dev)
if (dev->board.is_27xx) { if (dev->board.is_27xx) {
vinmode = 0x0d; vinmode = 0x0d;
vinctl = 0x00; vinctl = 0x00;
outfmt = 0x24;
} else { } else {
vinmode = 0x10; vinmode = 0x10;
vinctl = 0x11; vinctl = 0x11;
......
...@@ -90,15 +90,35 @@ MODULE_PARM_DESC(video_debug, "enable debug messages [video]"); ...@@ -90,15 +90,35 @@ MODULE_PARM_DESC(video_debug, "enable debug messages [video]");
/* supported video standards */ /* supported video standards */
static struct em28xx_fmt format[] = { static struct em28xx_fmt format[] = {
{ {
.name = "16bpp YUY2, 4:2:2, packed", .name = "16 bpp YUY2, 4:2:2, packed",
.fourcc = V4L2_PIX_FMT_YUYV, .fourcc = V4L2_PIX_FMT_YUYV,
.depth = 16, .depth = 16,
.reg = EM28XX_OUTFMT_YUV422_Y0UY1V, .reg = EM28XX_OUTFMT_YUV422_Y0UY1V,
}, { }, {
.name = "16 bpp RGB, le", .name = "16 bpp RGB 565, LE",
.fourcc = V4L2_PIX_FMT_RGB565, .fourcc = V4L2_PIX_FMT_RGB565,
.depth = 16, .depth = 16,
.reg = EM28XX_OUTFMT_YUV211, .reg = EM28XX_OUTFMT_RGB_16_656,
}, {
.name = "8 bpp Bayer BGBG..GRGR",
.fourcc = V4L2_PIX_FMT_SBGGR8,
.depth = 8,
.reg = EM28XX_OUTFMT_RGB_8_BGBG,
}, {
.name = "8 bpp Bayer GRGR..BGBG",
.fourcc = V4L2_PIX_FMT_SGRBG8,
.depth = 8,
.reg = EM28XX_OUTFMT_RGB_8_GRGR,
}, {
.name = "8 bpp Bayer GBGB..RGRG",
.fourcc = V4L2_PIX_FMT_SGBRG8,
.depth = 8,
.reg = EM28XX_OUTFMT_RGB_8_GBGB,
}, {
.name = "12 bpp YUV411",
.fourcc = V4L2_PIX_FMT_YUV411P,
.depth = 12,
.reg = EM28XX_OUTFMT_YUV411,
}, },
}; };
...@@ -699,10 +719,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, ...@@ -699,10 +719,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
unsigned int hscale, vscale; unsigned int hscale, vscale;
struct em28xx_fmt *fmt; struct em28xx_fmt *fmt;
/* FIXME: This is the only supported fmt */
if (dev->board.is_27xx)
f->fmt.pix.pixelformat = V4L2_PIX_FMT_RGB565;
fmt = format_by_fourcc(f->fmt.pix.pixelformat); fmt = format_by_fourcc(f->fmt.pix.pixelformat);
if (!fmt) { if (!fmt) {
em28xx_videodbg("Fourcc format (%08x) invalid.\n", em28xx_videodbg("Fourcc format (%08x) invalid.\n",
...@@ -753,7 +769,6 @@ static int em28xx_set_video_format(struct em28xx *dev, unsigned int fourcc, ...@@ -753,7 +769,6 @@ static int em28xx_set_video_format(struct em28xx *dev, unsigned int fourcc,
/* FIXME: This is the only supported fmt */ /* FIXME: This is the only supported fmt */
if (dev->board.is_27xx) { if (dev->board.is_27xx) {
fourcc = V4L2_PIX_FMT_RGB565;
width = 640; width = 640;
height = 480; height = 480;
} }
...@@ -1387,24 +1402,9 @@ static int vidioc_querycap(struct file *file, void *priv, ...@@ -1387,24 +1402,9 @@ static int vidioc_querycap(struct file *file, void *priv,
static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f) struct v4l2_fmtdesc *f)
{ {
struct em28xx_fh *fh = priv;
struct em28xx *dev = fh->dev;
if (unlikely(f->index >= ARRAY_SIZE(format))) if (unlikely(f->index >= ARRAY_SIZE(format)))
return -EINVAL; return -EINVAL;
if (dev->board.is_27xx) {
struct em28xx_fmt *fmt;
if (f->index)
return -EINVAL;
f->pixelformat = V4L2_PIX_FMT_RGB565;
fmt = format_by_fourcc(f->pixelformat);
strlcpy(f->description, fmt->name, sizeof(f->description));
return 0;
}
strlcpy(f->description, format[f->index].name, sizeof(f->description)); strlcpy(f->description, format[f->index].name, sizeof(f->description));
f->pixelformat = format[f->index].fourcc; f->pixelformat = format[f->index].fourcc;
......
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