From patchwork Fri Feb 12 09:26:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Abriou X-Patchwork-Id: 8289211 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 92791BEEE5 for ; Fri, 12 Feb 2016 09:26:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 93748203C1 for ; Fri, 12 Feb 2016 09:26:18 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 82C33203B7 for ; Fri, 12 Feb 2016 09:26:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DEE037A0C0; Fri, 12 Feb 2016 01:26:16 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [62.209.51.94]) by gabe.freedesktop.org (Postfix) with ESMTPS id 20D957A0C0 for ; Fri, 12 Feb 2016 01:26:15 -0800 (PST) Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by m0046037.ppops.net (8.15.0.59/8.15.0.59) with SMTP id u1C9LcSa004891; Fri, 12 Feb 2016 10:26:14 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by m0046037.ppops.net with ESMTP id 20w7fxb7ya-1 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 12 Feb 2016 10:26:14 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id EA0F338; Fri, 12 Feb 2016 09:25:20 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas22.st.com [10.75.90.92]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4E039F9E; Fri, 12 Feb 2016 09:26:13 +0000 (GMT) Received: from localhost (10.201.23.35) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 12 Feb 2016 10:26:12 +0100 From: Vincent Abriou To: Subject: [PATCH 2/2] drm/sti: support interlaced top / bottom field first Date: Fri, 12 Feb 2016 10:26:05 +0100 Message-ID: <1455269165-1564-3-git-send-email-vincent.abriou@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455269165-1564-1-git-send-email-vincent.abriou@st.com> References: <1455269165-1564-1-git-send-email-vincent.abriou@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.23.35] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-02-12_05:, , signatures=0 Cc: Vincent Abriou , Fabien Dessenne , Benjamin Gaignard 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-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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: Fabien Dessenne Support top field first and bottom field first interlaced buffers Signed-off-by: Fabien Dessenne --- drivers/gpu/drm/sti/sti_hqvdp.c | 72 +++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c index e9c33fb..e024c13 100644 --- a/drivers/gpu/drm/sti/sti_hqvdp.c +++ b/drivers/gpu/drm/sti/sti_hqvdp.c @@ -325,7 +325,7 @@ struct sti_hqvdp_cmd { * @clk_pix_main: pix main clock * @reset: reset control * @vtg_nb: notifier to handle VTG Vsync - * @btm_field_pending: is there any bottom field (interlaced frame) to display + * @nxt_field_pending: is there any other field (interlaced frame) to display * @hqvdp_cmd: buffer of commands * @hqvdp_cmd_paddr: physical address of hqvdp_cmd * @vtg: vtg for main data path @@ -340,7 +340,7 @@ struct sti_hqvdp { struct clk *clk_pix_main; struct reset_control *reset; struct notifier_block vtg_nb; - bool btm_field_pending; + bool nxt_field_pending; void *hqvdp_cmd; dma_addr_t hqvdp_cmd_paddr; struct sti_vtg *vtg; @@ -784,7 +784,7 @@ static void sti_hqvdp_disable(struct sti_hqvdp *hqvdp) * @evt: event message * @data: private data * - * Handle VTG Vsync event, display pending bottom field + * Handle VTG Vsync event, display next field * * RETURNS: * 0 on success. @@ -792,8 +792,8 @@ static void sti_hqvdp_disable(struct sti_hqvdp *hqvdp) int sti_hqvdp_vtg_cb(struct notifier_block *nb, unsigned long evt, void *data) { struct sti_hqvdp *hqvdp = container_of(nb, struct sti_hqvdp, vtg_nb); - int btm_cmd_offset, top_cmd_offest; - struct sti_hqvdp_cmd *btm_cmd, *top_cmd; + int next_cmd_offset, curr_cmd_offest; + struct sti_hqvdp_cmd *next_cmd, *curr_cmd; if ((evt != VTG_TOP_FIELD_EVENT) && (evt != VTG_BOTTOM_FIELD_EVENT)) { DRM_DEBUG_DRIVER("Unknown event\n"); @@ -808,31 +808,41 @@ int sti_hqvdp_vtg_cb(struct notifier_block *nb, unsigned long evt, void *data) sti_hqvdp_disable(hqvdp); } - if (hqvdp->btm_field_pending) { - /* Create the btm field command from the current one */ - btm_cmd_offset = sti_hqvdp_get_free_cmd(hqvdp); - top_cmd_offest = sti_hqvdp_get_curr_cmd(hqvdp); - if ((btm_cmd_offset == -1) || (top_cmd_offest == -1)) { + if (hqvdp->nxt_field_pending) { + /* Create the next field command from the current one */ + next_cmd_offset = sti_hqvdp_get_free_cmd(hqvdp); + curr_cmd_offest = sti_hqvdp_get_curr_cmd(hqvdp); + if ((next_cmd_offset == -1) || (curr_cmd_offest == -1)) { DRM_DEBUG_DRIVER("Warning: no cmd, will skip field\n"); return -EBUSY; } - btm_cmd = hqvdp->hqvdp_cmd + btm_cmd_offset; - top_cmd = hqvdp->hqvdp_cmd + top_cmd_offest; - - memcpy(btm_cmd, top_cmd, sizeof(*btm_cmd)); - - btm_cmd->top.config = TOP_CONFIG_INTER_BTM; - btm_cmd->top.current_luma += - btm_cmd->top.luma_src_pitch / 2; - btm_cmd->top.current_chroma += - btm_cmd->top.chroma_src_pitch / 2; + next_cmd = hqvdp->hqvdp_cmd + next_cmd_offset; + curr_cmd = hqvdp->hqvdp_cmd + curr_cmd_offest; + + memcpy(next_cmd, curr_cmd, sizeof(*next_cmd)); + + if (curr_cmd->top.config == TOP_CONFIG_INTER_TOP) { + /* Display the bottom field now */ + next_cmd->top.config = TOP_CONFIG_INTER_BTM; + next_cmd->top.current_luma += + next_cmd->top.luma_src_pitch / 2; + next_cmd->top.current_chroma += + next_cmd->top.chroma_src_pitch / 2; + } else { + /* Display the top field now */ + next_cmd->top.config = TOP_CONFIG_INTER_TOP; + next_cmd->top.current_luma -= + next_cmd->top.luma_src_pitch / 2; + next_cmd->top.current_chroma -= + next_cmd->top.chroma_src_pitch / 2; + } /* Post the command to mailbox */ - writel(hqvdp->hqvdp_cmd_paddr + btm_cmd_offset, - hqvdp->regs + HQVDP_MBX_NEXT_CMD); + writel(hqvdp->hqvdp_cmd_paddr + next_cmd_offset, + hqvdp->regs + HQVDP_MBX_NEXT_CMD); - hqvdp->btm_field_pending = false; + hqvdp->nxt_field_pending = false; dev_dbg(hqvdp->dev, "%s Posted command:0x%x\n", __func__, hqvdp->hqvdp_cmd_paddr); @@ -1077,7 +1087,7 @@ static int sti_hqvdp_atomic_check(struct drm_plane *drm_plane, return -EINVAL; } - /* Register VTG Vsync callback to handle bottom fields */ + /* Register VTG Vsync callback to handle bottom/top fields */ if (sti_vtg_register_client(hqvdp->vtg, &hqvdp->vtg_nb, crtc)) { @@ -1175,8 +1185,14 @@ static void sti_hqvdp_atomic_update(struct drm_plane *drm_plane, /* Handle interlaced */ if (fb->flags & DRM_MODE_FB_INTERLACED) { - /* Top field to display */ - cmd->top.config = TOP_CONFIG_INTER_TOP; + /* Top or bottom field */ + if (fb->flags & DRM_MODE_FB_BFF) { + cmd->top.config = TOP_CONFIG_INTER_BTM; + cmd->top.current_luma += cmd->top.luma_src_pitch; + cmd->top.current_chroma += cmd->top.chroma_src_pitch; + } else { + cmd->top.config = TOP_CONFIG_INTER_TOP; + } /* Update pitches and vert size */ cmd->top.input_frame_size = (src_h / 2) << 16 | src_w; @@ -1201,9 +1217,9 @@ static void sti_hqvdp_atomic_update(struct drm_plane *drm_plane, writel(hqvdp->hqvdp_cmd_paddr + cmd_offset, hqvdp->regs + HQVDP_MBX_NEXT_CMD); - /* Interlaced : get ready to display the bottom field at next Vsync */ + /* Interlaced : get ready to display the next field at next Vsync */ if (fb->flags & DRM_MODE_FB_INTERLACED) - hqvdp->btm_field_pending = true; + hqvdp->nxt_field_pending = true; dev_dbg(hqvdp->dev, "%s Posted command:0x%x\n", __func__, hqvdp->hqvdp_cmd_paddr + cmd_offset);