From patchwork Wed May 18 11:10:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damian Hobson-Garcia X-Patchwork-Id: 793432 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 p4IBDGCZ012239 for ; Wed, 18 May 2011 11:13:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932872Ab1ERLIu (ORCPT ); Wed, 18 May 2011 07:08:50 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:58604 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932125Ab1ERLIu (ORCPT ); Wed, 18 May 2011 07:08:50 -0400 Received: by mail-pz0-f46.google.com with SMTP id 9so654128pzk.19 for ; Wed, 18 May 2011 04:08:49 -0700 (PDT) Received: by 10.68.9.132 with SMTP id z4mr2666245pba.282.1305716929401; Wed, 18 May 2011 04:08:49 -0700 (PDT) Received: from localhost.localdomain (mailhost.igel.co.jp [219.106.231.130]) by mx.google.com with ESMTPS id l9sm996508pbc.14.2011.05.18.04.08.47 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 May 2011 04:08:48 -0700 (PDT) From: Damian Hobson-Garcia To: lethal@linux-sh.org Cc: linux-sh@vger.kernel.org, magnus.damm@gmail.com, taki@igel.co.jp, matsu@igel.co.jp, Damian Hobson-Garcia Subject: [PATCH 3/6] sh_mobile_meram: Add support for NV24 framebuffers Date: Wed, 18 May 2011 20:10:08 +0900 Message-Id: <1305717011-20742-4-git-send-email-dhobsong@igel.co.jp> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1305717011-20742-1-git-send-email-dhobsong@igel.co.jp> References: <1305717011-20742-1-git-send-email-dhobsong@igel.co.jp> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@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 11:13:17 +0000 (UTC) Since the NV24 framebuffer has a CbCr plane that is twice as wide as the Y plane, it needs to be handled as a special case. Signed-off-by: Damian Hobson-Garcia --- drivers/video/sh_mobile_lcdcfb.c | 10 +++++++--- drivers/video/sh_mobile_meram.c | 24 +++++++++++++++++++----- include/video/sh_mobile_meram.h | 3 ++- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c index 3a2cbd1..1c652da 100644 --- a/drivers/video/sh_mobile_lcdcfb.c +++ b/drivers/video/sh_mobile_lcdcfb.c @@ -627,10 +627,14 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ch->meram_enabled = 0; - if (ch->info->var.nonstd) - pf = SH_MOBILE_MERAM_PF_NV; - else + if (ch->info->var.nonstd) { + if (ch->info->var.bits_per_pixel == 24) + pf = SH_MOBILE_MERAM_PF_NV24; + else + pf = SH_MOBILE_MERAM_PF_NV; + } else { pf = SH_MOBILE_MERAM_PF_RGB; + } ret = mdev->ops->meram_register(mdev, cfg, pitch, ch->info->var.yres, diff --git a/drivers/video/sh_mobile_meram.c b/drivers/video/sh_mobile_meram.c index bd68f3d..9170c82 100644 --- a/drivers/video/sh_mobile_meram.c +++ b/drivers/video/sh_mobile_meram.c @@ -164,6 +164,16 @@ static inline void meram_unmark(struct sh_mobile_meram_priv *priv, } } +/* + * is this a YCbCr(NV12, NV16 or NV24) colorspace + */ +static inline int is_nvcolor(int cspace) +{ + if (cspace == SH_MOBILE_MERAM_PF_NV || + cspace == SH_MOBILE_MERAM_PF_NV24) + return 1; + return 0; +} /* * set the next address to fetch @@ -184,7 +194,7 @@ static inline void meram_set_next_addr(struct sh_mobile_meram_priv *priv, meram_write_icb(priv->base, cfg->icb[0].marker_icb, target, base_addr_y + cfg->icb[0].cache_unit); - if (cfg->pixelformat == SH_MOBILE_MERAM_PF_NV) { + if (is_nvcolor(cfg->pixelformat)) { meram_write_icb(priv->base, cfg->icb[1].cache_icb, target, base_addr_c); meram_write_icb(priv->base, cfg->icb[1].marker_icb, target, @@ -208,7 +218,7 @@ static inline void meram_get_next_icb_addr(struct sh_mobile_meram_info *pdata, icb_offset = 0xc0000000 | (cfg->current_reg << 23); *icb_addr_y = icb_offset | (cfg->icb[0].marker_icb << 24); - if ((*icb_addr_c) && cfg->pixelformat == SH_MOBILE_MERAM_PF_NV) + if ((*icb_addr_c) && is_nvcolor(cfg->pixelformat)) *icb_addr_c = icb_offset | (cfg->icb[1].marker_icb << 24); } @@ -316,6 +326,7 @@ static int sh_mobile_meram_register(struct sh_mobile_meram_info *pdata, return -EINVAL; if (pixelformat != SH_MOBILE_MERAM_PF_NV && + pixelformat != SH_MOBILE_MERAM_PF_NV24 && pixelformat != SH_MOBILE_MERAM_PF_RGB) return -EINVAL; @@ -366,7 +377,7 @@ static int sh_mobile_meram_register(struct sh_mobile_meram_info *pdata, n = 2; } - if (pixelformat == SH_MOBILE_MERAM_PF_NV && n != 2) { + if (is_nvcolor(pixelformat) && n != 2) { dev_err(&pdev->dev, "requires two ICB sets for planar Y/C."); error = -EINVAL; goto err; @@ -375,7 +386,7 @@ static int sh_mobile_meram_register(struct sh_mobile_meram_info *pdata, /* we now register the ICB */ cfg->pixelformat = pixelformat; meram_mark(priv, &cfg->icb[0]); - if (pixelformat == SH_MOBILE_MERAM_PF_NV) + if (is_nvcolor(pixelformat)) meram_mark(priv, &cfg->icb[1]); /* initialize MERAM */ @@ -384,6 +395,9 @@ static int sh_mobile_meram_register(struct sh_mobile_meram_info *pdata, if (pixelformat == SH_MOBILE_MERAM_PF_NV) meram_init(priv, &cfg->icb[1], xres, (yres + 1) / 2, &out_pitch); + else if (pixelformat == SH_MOBILE_MERAM_PF_NV24) + meram_init(priv, &cfg->icb[1], 2 * xres, (yres + 1) / 2, + &out_pitch); cfg->current_reg = 1; meram_set_next_addr(priv, cfg, base_addr_y, base_addr_c); @@ -410,7 +424,7 @@ static int sh_mobile_meram_unregister(struct sh_mobile_meram_info *pdata, mutex_lock(&priv->lock); /* deinit & unmark */ - if (cfg->pixelformat == SH_MOBILE_MERAM_PF_NV) { + if (is_nvcolor(cfg->pixelformat)) { meram_deinit(priv, &cfg->icb[1]); meram_unmark(priv, &cfg->icb[1]); } diff --git a/include/video/sh_mobile_meram.h b/include/video/sh_mobile_meram.h index 15fbb3d..af602d6 100644 --- a/include/video/sh_mobile_meram.h +++ b/include/video/sh_mobile_meram.h @@ -9,7 +9,8 @@ enum { enum { SH_MOBILE_MERAM_PF_NV = 0, - SH_MOBILE_MERAM_PF_RGB + SH_MOBILE_MERAM_PF_RGB, + SH_MOBILE_MERAM_PF_NV24 };