From patchwork Thu May 4 10:23:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 9711363 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8C72E60235 for ; Thu, 4 May 2017 10:24:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C59628682 for ; Thu, 4 May 2017 10:24:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6051328686; Thu, 4 May 2017 10:24:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9E1DD28682 for ; Thu, 4 May 2017 10:24:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ACF236E50A; Thu, 4 May 2017 10:24:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fllnx210.ext.ti.com (fllnx210.ext.ti.com [198.47.19.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id 58F9A6E504 for ; Thu, 4 May 2017 10:24:02 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v44AO0T0027838; Thu, 4 May 2017 05:24:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1493893440; bh=3LFokB5MRChg+QRgaokcXpzxmf4j5LZ0f1bPmwoLdA8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Y4r+V+U95FJNWjh1hLckU8mxFYkaX44Qk9n9AQ1sF59aRcL6mipmgdXjFtxN6ENYa 3cJQI8LJMZMXBRNDDEkOxd175yZv0rBnDKBamdFmpcXWKhneDO1nuAJooQIEazNDJf FJ0O0cZo+8jrEBrBhDkZ6iuyH0tKLJopVFdxjsBg= Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v44ANxiB014807; Thu, 4 May 2017 05:24:00 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.294.0; Thu, 4 May 2017 05:23:59 -0500 Received: from deskari.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v44ANZsP019135; Thu, 4 May 2017 05:23:58 -0500 From: Tomi Valkeinen To: , Laurent Pinchart Subject: [PATCH 15/16] drm/omap: cleanup formats array Date: Thu, 4 May 2017 13:23:31 +0300 Message-ID: <1493893412-12178-16-git-send-email-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493893412-12178-1-git-send-email-tomi.valkeinen@ti.com> References: <1493893412-12178-1-git-send-email-tomi.valkeinen@ti.com> MIME-Version: 1.0 Cc: Tomi Valkeinen , Jyri Sarha X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP omap_fb.c has a table with DSS and DRM formats, used to convert between them. This is no longer needed, so we can change the array to a plain array of DRM_FORMAT_* values which contain all possible pixel formats supported by any DSS IP version. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/omap_fb.c | 49 ++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index ec60620fe2d1..11fb8cf55e57 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -29,30 +29,26 @@ * framebuffer funcs */ -/* DSS to DRM formats mapping */ -static const struct { - u32 dss_format; - uint32_t pixel_format; -} formats[] = { +static const u32 formats[] = { /* 16bpp [A]RGB: */ - { DRM_FORMAT_RGB565, DRM_FORMAT_RGB565 }, /* RGB16-565 */ - { DRM_FORMAT_RGBX4444, DRM_FORMAT_RGBX4444 }, /* RGB12x-4444 */ - { DRM_FORMAT_XRGB4444, DRM_FORMAT_XRGB4444 }, /* xRGB12-4444 */ - { DRM_FORMAT_RGBA4444, DRM_FORMAT_RGBA4444 }, /* RGBA12-4444 */ - { DRM_FORMAT_ARGB4444, DRM_FORMAT_ARGB4444 }, /* ARGB16-4444 */ - { DRM_FORMAT_XRGB1555, DRM_FORMAT_XRGB1555 }, /* xRGB15-1555 */ - { DRM_FORMAT_ARGB1555, DRM_FORMAT_ARGB1555 }, /* ARGB16-1555 */ + DRM_FORMAT_RGB565, /* RGB16-565 */ + DRM_FORMAT_RGBX4444, /* RGB12x-4444 */ + DRM_FORMAT_XRGB4444, /* xRGB12-4444 */ + DRM_FORMAT_RGBA4444, /* RGBA12-4444 */ + DRM_FORMAT_ARGB4444, /* ARGB16-4444 */ + DRM_FORMAT_XRGB1555, /* xRGB15-1555 */ + DRM_FORMAT_ARGB1555, /* ARGB16-1555 */ /* 24bpp RGB: */ - { DRM_FORMAT_RGB888, DRM_FORMAT_RGB888 }, /* RGB24-888 */ + DRM_FORMAT_RGB888, /* RGB24-888 */ /* 32bpp [A]RGB: */ - { DRM_FORMAT_RGBX8888, DRM_FORMAT_RGBX8888 }, /* RGBx24-8888 */ - { DRM_FORMAT_XRGB8888, DRM_FORMAT_XRGB8888 }, /* xRGB24-8888 */ - { DRM_FORMAT_RGBA8888, DRM_FORMAT_RGBA8888 }, /* RGBA32-8888 */ - { DRM_FORMAT_ARGB8888, DRM_FORMAT_ARGB8888 }, /* ARGB32-8888 */ + DRM_FORMAT_RGBX8888, /* RGBx24-8888 */ + DRM_FORMAT_XRGB8888, /* xRGB24-8888 */ + DRM_FORMAT_RGBA8888, /* RGBA32-8888 */ + DRM_FORMAT_ARGB8888, /* ARGB32-8888 */ /* YUV: */ - { DRM_FORMAT_NV12, DRM_FORMAT_NV12 }, - { DRM_FORMAT_YUYV, DRM_FORMAT_YUYV }, - { DRM_FORMAT_UYVY, DRM_FORMAT_UYVY }, + DRM_FORMAT_NV12, + DRM_FORMAT_YUYV, + DRM_FORMAT_UYVY, }; /* per-plane info for the fb: */ @@ -69,7 +65,6 @@ struct omap_framebuffer { struct drm_framebuffer base; int pin_count; const struct drm_format_info *format; - u32 dss_format; struct plane planes[2]; /* lock for pinning (pin_count and planes.paddr) */ struct mutex lock; @@ -137,7 +132,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, struct plane *plane = &omap_fb->planes[0]; uint32_t x, y, orient = 0; - info->color_mode = omap_fb->dss_format; + info->color_mode = fb->format->format; info->pos_x = win->crtc_x; info->pos_y = win->crtc_y; @@ -225,7 +220,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, /* convert to pixels: */ info->screen_width /= format->cpp[0]; - if (omap_fb->dss_format == DRM_FORMAT_NV12) { + if (fb->format->format == DRM_FORMAT_NV12) { plane = &omap_fb->planes[1]; if (info->rotation_type == OMAP_DSS_ROT_TILER) { @@ -384,7 +379,6 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, const struct drm_format_info *format = NULL; struct omap_framebuffer *omap_fb = NULL; struct drm_framebuffer *fb = NULL; - u32 dss_format = 0; unsigned int pitch = mode_cmd->pitches[0]; int ret, i; @@ -395,13 +389,11 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, format = drm_format_info(mode_cmd->pixel_format); for (i = 0; i < ARRAY_SIZE(formats); i++) { - if (formats[i].pixel_format == mode_cmd->pixel_format) { - dss_format = formats[i].dss_format; + if (formats[i] == mode_cmd->pixel_format) break; - } } - if (!format || !dss_format) { + if (!format || i == ARRAY_SIZE(formats)) { dev_dbg(dev->dev, "unsupported pixel format: %4.4s\n", (char *)&mode_cmd->pixel_format); ret = -EINVAL; @@ -416,7 +408,6 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, fb = &omap_fb->base; omap_fb->format = format; - omap_fb->dss_format = dss_format; mutex_init(&omap_fb->lock); /*