From patchwork Wed May 18 14:11:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 793722 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4IEEKh1008864 for ; Wed, 18 May 2011 14:14:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932964Ab1EROLw (ORCPT ); Wed, 18 May 2011 10:11:52 -0400 Received: from moutng.kundenserver.de ([212.227.17.10]:49190 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932648Ab1EROLw (ORCPT ); Wed, 18 May 2011 10:11:52 -0400 Received: from axis700.grange (dslb-178-001-149-207.pools.arcor-ip.net [178.1.149.207]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0LjuTB-1PpISo0n7J-00cEa6; Wed, 18 May 2011 16:11:31 +0200 Received: by axis700.grange (Postfix, from userid 1000) id C4C19189B6B; Wed, 18 May 2011 16:11:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id C1297189B66 for ; Wed, 18 May 2011 16:11:30 +0200 (CEST) Date: Wed, 18 May 2011 16:11:30 +0200 (CEST) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: Linux Media Mailing List Subject: [PATCH 2/5] V4L: omap1-camera: fix huge lookup array In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Provags-ID: V02:K0:I4sbFBh4ZCt9ltx8tn2ZpRPtwpWJECDCq7A21H7RbNt 3RPlRwtl4yqLgjf3NCHL3p80qvm9dQpeCwipJWGdVT3huwgzAu FqJ6IfmeYXJHk19tabWfnSsnZ+tgukXHMgq8HVdtlTgbuyiZDc 7ucHPY46bN02B56bFjNh5GOsVXuRK3EodVbzJnSphRt8eoo/G/ 1rKDNxZg7w4PFmn9skjuNZ7Ugw8xThoYa4S+4RtsZg= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 18 May 2011 14:14:22 +0000 (UTC) Since V4L2_MBUS_FMT_* codes have become large and sparse, they cannot be used as array indices anymore. Signed-off-by: Guennadi Liakhovetski --- drivers/media/video/omap1_camera.c | 41 ++++++++++++++++++++++++++--------- 1 files changed, 30 insertions(+), 11 deletions(-) diff --git a/drivers/media/video/omap1_camera.c b/drivers/media/video/omap1_camera.c index 5954b93..fe577a9 100644 --- a/drivers/media/video/omap1_camera.c +++ b/drivers/media/video/omap1_camera.c @@ -990,63 +990,80 @@ static void omap1_cam_remove_device(struct soc_camera_device *icd) } /* Duplicate standard formats based on host capability of byte swapping */ -static const struct soc_mbus_pixelfmt omap1_cam_formats[] = { - [V4L2_MBUS_FMT_UYVY8_2X8] = { +static const struct soc_mbus_lookup omap1_cam_formats[] = { +{ + .code = V4L2_MBUS_FMT_UYVY8_2X8, + .fmt = { .fourcc = V4L2_PIX_FMT_YUYV, .name = "YUYV", .bits_per_sample = 8, .packing = SOC_MBUS_PACKING_2X8_PADHI, .order = SOC_MBUS_ORDER_BE, }, - [V4L2_MBUS_FMT_VYUY8_2X8] = { +}, { + .code = V4L2_MBUS_FMT_VYUY8_2X8, + .fmt = { .fourcc = V4L2_PIX_FMT_YVYU, .name = "YVYU", .bits_per_sample = 8, .packing = SOC_MBUS_PACKING_2X8_PADHI, .order = SOC_MBUS_ORDER_BE, }, - [V4L2_MBUS_FMT_YUYV8_2X8] = { +}, { + .code = V4L2_MBUS_FMT_YUYV8_2X8, + .fmt = { .fourcc = V4L2_PIX_FMT_UYVY, .name = "UYVY", .bits_per_sample = 8, .packing = SOC_MBUS_PACKING_2X8_PADHI, .order = SOC_MBUS_ORDER_BE, }, - [V4L2_MBUS_FMT_YVYU8_2X8] = { +}, { + .code = V4L2_MBUS_FMT_YVYU8_2X8, + .fmt = { .fourcc = V4L2_PIX_FMT_VYUY, .name = "VYUY", .bits_per_sample = 8, .packing = SOC_MBUS_PACKING_2X8_PADHI, .order = SOC_MBUS_ORDER_BE, }, - [V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE] = { +}, { + .code = V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE, + .fmt = { .fourcc = V4L2_PIX_FMT_RGB555, .name = "RGB555", .bits_per_sample = 8, .packing = SOC_MBUS_PACKING_2X8_PADHI, .order = SOC_MBUS_ORDER_BE, }, - [V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE] = { +}, { + .code = V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, + .fmt = { .fourcc = V4L2_PIX_FMT_RGB555X, .name = "RGB555X", .bits_per_sample = 8, .packing = SOC_MBUS_PACKING_2X8_PADHI, .order = SOC_MBUS_ORDER_BE, }, - [V4L2_MBUS_FMT_RGB565_2X8_BE] = { +}, { + .code = V4L2_MBUS_FMT_RGB565_2X8_BE, + .fmt = { .fourcc = V4L2_PIX_FMT_RGB565, .name = "RGB565", .bits_per_sample = 8, .packing = SOC_MBUS_PACKING_2X8_PADHI, .order = SOC_MBUS_ORDER_BE, }, - [V4L2_MBUS_FMT_RGB565_2X8_LE] = { +}, { + .code = V4L2_MBUS_FMT_RGB565_2X8_LE, + .fmt = { .fourcc = V4L2_PIX_FMT_RGB565X, .name = "RGB565X", .bits_per_sample = 8, .packing = SOC_MBUS_PACKING_2X8_PADHI, .order = SOC_MBUS_ORDER_BE, }, +}, }; static int omap1_cam_get_formats(struct soc_camera_device *icd, @@ -1085,12 +1102,14 @@ static int omap1_cam_get_formats(struct soc_camera_device *icd, case V4L2_MBUS_FMT_RGB565_2X8_LE: formats++; if (xlate) { - xlate->host_fmt = &omap1_cam_formats[code]; + xlate->host_fmt = soc_mbus_find_fmtdesc(code, + omap1_cam_formats, + ARRAY_SIZE(omap1_cam_formats)); xlate->code = code; xlate++; dev_dbg(dev, "%s: providing format %s as byte swapped code #%d\n", - __func__, omap1_cam_formats[code].name, code); + __func__, xlate->host_fmt->name, code); } default: if (xlate)