From: Guennadi Liakhovetski Date: Mon, 23 Feb 2009 15:12:58 +0000 (-0300) Subject: V4L/DVB (10672): sh_mobile_ceu_camera: include NV* formats into the format list only... X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c8329accf7e75a8a8fbe4ad0a15a3eacf221f380;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git V4L/DVB (10672): sh_mobile_ceu_camera: include NV* formats into the format list only once. Currently, if an soc-camera device, connected to the sh_mobile_ceu_camera camera host driver, supports several formats from the UYVY, VYUY, YUYV, YVYU set, the driver would add four NV* formats for each of them. This patch fixes this misbehaviour. Reported-by: Kuninori Morimoto Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c index 8a1badba70f7..ed3bfc4cf9f9 100644 --- a/drivers/media/video/sh_mobile_ceu_camera.c +++ b/drivers/media/video/sh_mobile_ceu_camera.c @@ -586,11 +586,29 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, int idx, if (ret < 0) return 0; + /* Beginning of a pass */ + if (!idx) + icd->host_priv = NULL; + switch (icd->formats[idx].fourcc) { case V4L2_PIX_FMT_UYVY: case V4L2_PIX_FMT_VYUY: case V4L2_PIX_FMT_YUYV: case V4L2_PIX_FMT_YVYU: + if (icd->host_priv) + goto add_single_format; + + /* + * Our case is simple so far: for any of the above four camera + * formats we add all our four synthesized NV* formats, so, + * just marking the device with a single flag suffices. If + * the format generation rules are more complex, you would have + * to actually hang your already added / counted formats onto + * the host_priv pointer and check whether the format you're + * going to add now is already there. + */ + icd->host_priv = (void *)sh_mobile_ceu_formats; + n = ARRAY_SIZE(sh_mobile_ceu_formats); formats += n; for (k = 0; xlate && k < n; k++) { @@ -603,6 +621,7 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, int idx, icd->formats[idx].name); } default: +add_single_format: /* Generic pass-through */ formats++; if (xlate) {