[media] atmel-isi: support RGB565 output when sensor output YUV formats

This patch enable Atmel ISI preview path to convert the YUV to RGB format.

Signed-off-by: Josh Wu <josh.wu@atmel.com>
[g.liakhovetski@gmx.de: removed superfluous parentheses]
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
This commit is contained in:
Josh Wu 2015-11-03 03:45:12 -02:00 committed by Mauro Carvalho Chehab
parent 7393de60a2
commit 05645a46a1

View file

@ -146,6 +146,10 @@ static void configure_geometry(struct atmel_isi *isi, u32 width,
u32 height, const struct soc_camera_format_xlate *xlate) u32 height, const struct soc_camera_format_xlate *xlate)
{ {
u32 cfg2, psize; u32 cfg2, psize;
u32 fourcc = xlate->host_fmt->fourcc;
isi->enable_preview_path = fourcc == V4L2_PIX_FMT_RGB565 ||
fourcc == V4L2_PIX_FMT_RGB32;
/* According to sensor's output format to set cfg2 */ /* According to sensor's output format to set cfg2 */
switch (xlate->code) { switch (xlate->code) {
@ -195,8 +199,9 @@ static bool is_supported(struct soc_camera_device *icd,
case V4L2_PIX_FMT_UYVY: case V4L2_PIX_FMT_UYVY:
case V4L2_PIX_FMT_YVYU: case V4L2_PIX_FMT_YVYU:
case V4L2_PIX_FMT_VYUY: case V4L2_PIX_FMT_VYUY:
/* RGB */
case V4L2_PIX_FMT_RGB565:
return true; return true;
/* RGB, TODO */
default: default:
return false; return false;
} }
@ -686,6 +691,14 @@ static const struct soc_mbus_pixelfmt isi_camera_formats[] = {
.order = SOC_MBUS_ORDER_LE, .order = SOC_MBUS_ORDER_LE,
.layout = SOC_MBUS_LAYOUT_PACKED, .layout = SOC_MBUS_LAYOUT_PACKED,
}, },
{
.fourcc = V4L2_PIX_FMT_RGB565,
.name = "RGB565",
.bits_per_sample = 8,
.packing = SOC_MBUS_PACKING_2X8_PADHI,
.order = SOC_MBUS_ORDER_LE,
.layout = SOC_MBUS_LAYOUT_PACKED,
},
}; };
/* This will be corrected as we get more formats */ /* This will be corrected as we get more formats */
@ -742,7 +755,7 @@ static int isi_camera_get_formats(struct soc_camera_device *icd,
struct soc_camera_format_xlate *xlate) struct soc_camera_format_xlate *xlate)
{ {
struct v4l2_subdev *sd = soc_camera_to_subdev(icd); struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
int formats = 0, ret; int formats = 0, ret, i, n;
/* sensor format */ /* sensor format */
struct v4l2_subdev_mbus_code_enum code = { struct v4l2_subdev_mbus_code_enum code = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE, .which = V4L2_SUBDEV_FORMAT_ACTIVE,
@ -776,11 +789,11 @@ static int isi_camera_get_formats(struct soc_camera_device *icd,
case MEDIA_BUS_FMT_VYUY8_2X8: case MEDIA_BUS_FMT_VYUY8_2X8:
case MEDIA_BUS_FMT_YUYV8_2X8: case MEDIA_BUS_FMT_YUYV8_2X8:
case MEDIA_BUS_FMT_YVYU8_2X8: case MEDIA_BUS_FMT_YVYU8_2X8:
formats++; n = ARRAY_SIZE(isi_camera_formats);
if (xlate) { formats += n;
xlate->host_fmt = &isi_camera_formats[0]; for (i = 0; xlate && i < n; i++, xlate++) {
xlate->host_fmt = &isi_camera_formats[i];
xlate->code = code.code; xlate->code = code.code;
xlate++;
dev_dbg(icd->parent, "Providing format %s using code %d\n", dev_dbg(icd->parent, "Providing format %s using code %d\n",
isi_camera_formats[0].name, code.code); isi_camera_formats[0].name, code.code);
} }