From patchwork Mon Mar 5 16:48:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 7090 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id F3C8923DC3 for ; Mon, 5 Mar 2012 16:49:02 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id B3ECCA18182 for ; Mon, 5 Mar 2012 16:49:02 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so7746420iag.11 for ; Mon, 05 Mar 2012 08:49:02 -0800 (PST) Received: by 10.50.85.202 with SMTP id j10mr6081216igz.58.1330966142508; Mon, 05 Mar 2012 08:49:02 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.53.18 with SMTP id k18csp30872ibg; Mon, 5 Mar 2012 08:49:02 -0800 (PST) Received: by 10.236.79.193 with SMTP id i41mr21870642yhe.16.1330966141438; Mon, 05 Mar 2012 08:49:01 -0800 (PST) Received: from mail-gy0-f178.google.com (mail-gy0-f178.google.com [209.85.160.178]) by mx.google.com with ESMTPS id d9si16881028yhn.135.2012.03.05.08.49.01 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 05 Mar 2012 08:49:01 -0800 (PST) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.160.178 as permitted sender) client-ip=209.85.160.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.160.178 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by ghbf1 with SMTP id f1so2032935ghb.37 for ; Mon, 05 Mar 2012 08:49:01 -0800 (PST) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 10.236.192.137 as permitted sender) client-ip=10.236.192.137; Received: from mr.google.com ([10.236.192.137]) by 10.236.192.137 with SMTP id i9mr27441002yhn.115.1330966141258 (num_hops = 1); Mon, 05 Mar 2012 08:49:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=GVLirMZWWjYYW4ZR1Bfn9Pg2ZnV6hrODydPK4mIwn9o=; b=QlwBce176utF3MWqoJgtWtY+YTJLdk3AfJDJQl0b+CvduFpQ6mB835CUjAWACuoHD2 6zB4LQQ7ezGLHe4+thRJe/FYE+YV3A7usfnFN3nhzQ6vNcjCocJqSWMadFjQTuPzxJIl sZ4ObB+G7oDcSyeUjSvvC/IFOiafm1uEUYKdn7E6+L4Urf4d0vJ32KF3h6E68LbkzPTx RTSrXj/c7jwkkKNfvv9aMN6mKXWp8rZG7hIKIhdYpNAOgFrFzoo/mSPoeUylZnAUrebA U/SmXFKabfsx+CUEBVMHmDVIvM4w8FB1QEsZqjv37PpARdgn5/PGhwZMGNLoIjROQAM0 oNkQ== Received: by 10.236.192.137 with SMTP id i9mr21627091yhn.115.1330966141205; Mon, 05 Mar 2012 08:49:01 -0800 (PST) Received: from localhost (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id z27sm41414998yhh.8.2012.03.05.08.49.00 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 05 Mar 2012 08:49:00 -0800 (PST) Sender: Rob Clark From: Rob Clark To: dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org Cc: patches@linaro.org, Greg KH , Tomi Valkeinen , Andy Gross , Rob Clark Subject: [PATCH 01/10] staging: drm/omap: get supported color formats from ovl Date: Mon, 5 Mar 2012 10:48:31 -0600 Message-Id: <1330966120-28582-2-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1330966120-28582-1-git-send-email-rob.clark@linaro.org> References: <1330966120-28582-1-git-send-email-rob.clark@linaro.org> X-Gm-Message-State: ALoCoQnnzDjfJu080Ab3bURnyO0XqLRhMajzZnsn71Q6JA0P7L3GJ20vO23u+PtBBS3Dnnz3p6cS From: Rob Clark Get the supported formats for a plane from ovl's supported_modes bitmask. Signed-off-by: Rob Clark --- drivers/staging/omapdrm/omap_drv.h | 2 ++ drivers/staging/omapdrm/omap_fb.c | 14 ++++++++++++++ drivers/staging/omapdrm/omap_plane.c | 27 +++++++-------------------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/drivers/staging/omapdrm/omap_drv.h b/drivers/staging/omapdrm/omap_drv.h index 61fe022..d924c95 100644 --- a/drivers/staging/omapdrm/omap_drv.h +++ b/drivers/staging/omapdrm/omap_drv.h @@ -92,6 +92,8 @@ void omap_connector_mode_set(struct drm_connector *connector, void omap_connector_flush(struct drm_connector *connector, int x, int y, int w, int h); +uint32_t omap_framebuffer_get_formats(uint32_t *pixel_formats, + uint32_t max_formats, enum omap_color_mode supported_modes); struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev, struct drm_file *file, struct drm_mode_fb_cmd2 *mode_cmd); struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, diff --git a/drivers/staging/omapdrm/omap_fb.c b/drivers/staging/omapdrm/omap_fb.c index d021a7e..116a8ff 100644 --- a/drivers/staging/omapdrm/omap_fb.c +++ b/drivers/staging/omapdrm/omap_fb.c @@ -59,6 +59,20 @@ static const struct format formats[] = { { OMAP_DSS_COLOR_UYVY, DRM_FORMAT_UYVY, {{2, 1}}, true }, }; +/* convert from overlay's pixel formats bitmask to an array of fourcc's */ +uint32_t omap_framebuffer_get_formats(uint32_t *pixel_formats, + uint32_t max_formats, enum omap_color_mode supported_modes) +{ + uint32_t nformats = 0; + int i = 0; + + for (i = 0; i < ARRAY_SIZE(formats) && nformats < max_formats; i++) + if (formats[i].dss_format & supported_modes) + pixel_formats[nformats++] = formats[i].pixel_format; + + return nformats; +} + /* per-plane info for the fb: */ struct plane { struct drm_gem_object *bo; diff --git a/drivers/staging/omapdrm/omap_plane.c b/drivers/staging/omapdrm/omap_plane.c index 9790912..c5625e3 100644 --- a/drivers/staging/omapdrm/omap_plane.c +++ b/drivers/staging/omapdrm/omap_plane.c @@ -43,8 +43,10 @@ struct omap_plane { /* last fb that we pinned: */ struct drm_framebuffer *pinned_fb; -}; + uint32_t nformats; + uint32_t formats[32]; +}; /* push changes down to dss2 */ static int commit(struct drm_plane *plane) @@ -271,24 +273,6 @@ static const struct drm_plane_funcs omap_plane_funcs = { .destroy = omap_plane_destroy, }; -static const uint32_t formats[] = { - DRM_FORMAT_RGB565, - DRM_FORMAT_RGBX4444, - DRM_FORMAT_XRGB4444, - DRM_FORMAT_RGBA4444, - DRM_FORMAT_ABGR4444, - DRM_FORMAT_XRGB1555, - DRM_FORMAT_ARGB1555, - DRM_FORMAT_RGB888, - DRM_FORMAT_RGBX8888, - DRM_FORMAT_XRGB8888, - DRM_FORMAT_RGBA8888, - DRM_FORMAT_ARGB8888, - DRM_FORMAT_NV12, - DRM_FORMAT_YUYV, - DRM_FORMAT_UYVY, -}; - /* initialize plane */ struct drm_plane *omap_plane_init(struct drm_device *dev, struct omap_overlay *ovl, unsigned int possible_crtcs, @@ -306,11 +290,14 @@ struct drm_plane *omap_plane_init(struct drm_device *dev, goto fail; } + omap_plane->nformats = omap_framebuffer_get_formats( + omap_plane->formats, ARRAY_SIZE(omap_plane->formats), + ovl->supported_modes); omap_plane->ovl = ovl; plane = &omap_plane->base; drm_plane_init(dev, plane, possible_crtcs, &omap_plane_funcs, - formats, ARRAY_SIZE(formats), priv); + omap_plane->formats, omap_plane->nformats, priv); /* get our starting configuration, set defaults for parameters * we don't currently use, etc: