From patchwork Fri Feb 26 18:42:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cox X-Patchwork-Id: 8440981 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4374E9F314 for ; Fri, 26 Feb 2016 18:42:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 57FC120259 for ; Fri, 26 Feb 2016 18:42:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 611FE20222 for ; Fri, 26 Feb 2016 18:42:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422790AbcBZSml (ORCPT ); Fri, 26 Feb 2016 13:42:41 -0500 Received: from lxorguk.ukuu.org.uk ([81.2.110.251]:54530 "EHLO lxorguk.ukuu.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422711AbcBZSmk (ORCPT ); Fri, 26 Feb 2016 13:42:40 -0500 Received: from localhost.localdomain (proxy [81.2.110.250]) by lxorguk.ukuu.org.uk (8.15.2/8.14.1) with ESMTP id u1QJL9O7006247; Fri, 26 Feb 2016 19:21:14 GMT Subject: [PATCH 5/5] Subject: goldfishfb: simplify framebuffer format selection. From: Alan To: linux-fbdev@vger.kernel.org, tomi.valkeinen@ti.com, plagnioj@jcrosoft.com Date: Fri, 26 Feb 2016 18:42:30 +0000 Message-ID: <20160226184230.2731.4181.stgit@localhost.localdomain> In-Reply-To: <20160226183940.2731.42083.stgit@localhost.localdomain> References: <20160226183940.2731.42083.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Nicolas Capens Signed-off-by: Nicolas Capens Signed-off-by: Jin Qian Signed-off-by: Alan Cox --- drivers/video/fbdev/goldfishfb.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/video/fbdev/goldfishfb.c b/drivers/video/fbdev/goldfishfb.c index cddc91d..2a5fe71 100644 --- a/drivers/video/fbdev/goldfishfb.c +++ b/drivers/video/fbdev/goldfishfb.c @@ -53,39 +53,35 @@ enum { HAL_PIXEL_FORMAT_RGB_888 = 3, HAL_PIXEL_FORMAT_RGB_565 = 4, HAL_PIXEL_FORMAT_BGRA_8888 = 5, - HAL_PIXEL_FORMAT_RGBA_5551 = 6, - HAL_PIXEL_FORMAT_RGBA_4444 = 7, }; struct framebuffer_config { - u8 format; u8 bytes_per_pixel; - u8 transp_offset; - u8 transp_length; u8 red_offset; u8 red_length; u8 green_offset; u8 green_length; u8 blue_offset; u8 blue_length; + u8 transp_offset; + u8 transp_length; +}; + +static const struct framebuffer_config fb_configs[] = { + { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Invalid, assume RGB_565 */ + { 4, 0, 8, 8, 8, 16, 8, 24, 8 }, /* HAL_PIXEL_FORMAT_RGBA_8888 */ + { 4, 0, 8, 8, 8, 16, 8, 0, 0 }, /* HAL_PIXEL_FORMAT_RGBX_8888 */ + { 3, 0, 8, 8, 8, 16, 8, 0, 0 }, /* HAL_PIXEL_FORMAT_RGB_888 */ + { 2, 11, 5, 5, 6, 0, 5, 0, 0 }, /* HAL_PIXEL_FORMAT_RGB_565 */ + { 4, 16, 8, 8, 8, 0, 8, 24, 8 }, /* HAL_PIXEL_FORMAT_BGRA_8888 */ }; static const struct framebuffer_config *get_fb_config_from_format(int format) { - /* Only configurations supported by the emulator. */ - static const struct framebuffer_config fb_configs[] = { - { HAL_PIXEL_FORMAT_RGB_565, 2, 0, 0, 11, 5, 5, 6, 0, 5 }, - { HAL_PIXEL_FORMAT_RGBX_8888, 4, 0, 0, 16, 8, 8, 8, 0, 8 }, - { HAL_PIXEL_FORMAT_RGBA_8888, 4, 24, 8, 16, 8, 8, 8, 0, 8 }, - }; - const int fb_configs_size = ARRAY_SIZE(fb_configs); - int n; - - for (n = 0; n < fb_configs_size; ++n) { - if (format == fb_configs[n].format) - return &fb_configs[n]; - } - return &fb_configs[0]; /* default to RGB565 */ + if (format > 0 && format < ARRAY_SIZE(fb_configs)) + return &fb_configs[format]; + + return &fb_configs[HAL_PIXEL_FORMAT_RGB_565]; /* legacy default */ } struct goldfish_fb {