Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4083869ybb; Mon, 6 Apr 2020 23:59:10 -0700 (PDT) X-Google-Smtp-Source: APiQypJb/9rJTO54wAMz7Ocp1EmUbKjotMnD0oOSocVPvBqcnIWuNwwvpRmBo0m1900ZwwHFYM2b X-Received: by 2002:aca:c142:: with SMTP id r63mr624095oif.25.1586242750318; Mon, 06 Apr 2020 23:59:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586242750; cv=none; d=google.com; s=arc-20160816; b=Bozc+xEMSy9CAAmg1/RFuV+ju2pSqlH2r4DJAUzidMPEEn+8/Aof+2q+l+upvurLx9 2p3lfc21B/l+VFhvC6VGPNNtQFzG6dcdk83MkOwpu/J2JD5bbeYpAkMrZ4Sf2vrBqRtG LuyR/Dl2O77AYRWCiqx/ua9ClDVtl8Thh5var6WdboE8j/wT8eCJ/ydRbJGfPW+fdkOR q7dfFqlzDRa1ATKlz6hERuJj65/9pJ6efZ1PfPPkt0j7+CjQNIV95l70vTSm4h95HTtm GtDTr3nkjwBn29NI5GK3MA7uulB+GTzm6Bo9m7KgHEQV+svrP8t+SosuMp8HiHa1ej3g 283g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PTus1HhmAwjgtZusz47Cocd0rsgHoslXEjkAB1idN5Y=; b=l/y0w6jthTIzGMBNHoVJEKPgOGlZsM1DXn+/qF3nRhMBgdB5c2jLXcYvkZVEeijNsS nymJbg/QGVaC9lOUnocUS2a+DEk07CHXNh9FQQm4BF1fkVmlO0AxR3AO50AaqE+OTm5S xnjLrKiOt8A+0+tAyxEEOlmu+G12+AbwkMJ4RtYAmjiA5oAfGQ3oo07K5OS8XnAiOEbm DBI1di9bm/0HqBcOMYgCDwn5XmJv1hlm/PYjrwFfqz5t0eYK4QLUcEYt/ADvsrXZ2PHd eW+m/Nvtvj5FFECkohSkSCA1U6TM0AYzakqlh2Qpvvxdkn6kzt/KOVICjr9Oo9OnoJPR iZ3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LmLVHk5R; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k70si790053oih.24.2020.04.06.23.58.58; Mon, 06 Apr 2020 23:59:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LmLVHk5R; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727235AbgDGG62 (ORCPT + 99 others); Tue, 7 Apr 2020 02:58:28 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:35459 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726591AbgDGG62 (ORCPT ); Tue, 7 Apr 2020 02:58:28 -0400 Received: by mail-ed1-f65.google.com with SMTP id c7so2710820edl.2 for ; Mon, 06 Apr 2020 23:58:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PTus1HhmAwjgtZusz47Cocd0rsgHoslXEjkAB1idN5Y=; b=LmLVHk5Rma0Nob96e5PCxTU6PBnIl0GKYt6IMfMuzeXl+Cn+IpD0cHqvZKFogzUDYb 20M8qavHrZJ/oppK4Axr2ZxPsKYyRwS0c3r0ClLn+V3m9cUxz43hoiwh8Ht9t01HGuIl aTvN0D+uzaCS6c8K3uVAILkdncJrNCXRr0W8N/zyEbrU3KaZJ+VpZW9yxL+oCRJgW69+ K11w5iz8ViJuSUUq72JQ5h3Pbs0q7pOUytT47Eg77EbM/Xa5HwkRuGX3Wk+6w7VR2E1a OLZfq1v08YKU5Ya3f3ks/YBeH3UN9VPl7oQ5xHXJ2252OPK+Wf2jSoIFIVdGG9EZ3nqd TiCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PTus1HhmAwjgtZusz47Cocd0rsgHoslXEjkAB1idN5Y=; b=dCkhjxcAZ7cMIICruaK5y1aANiX2GIsXh16GlHvuJWzi6g2lliASNKiUJ8w1ux5ohP VRJug2a7Sh9XYColqlhyiDLsnWa0eAwJNuSdq8H6xvKrel3yyTrMgWkQs/ajHqZ3CtRP nxED/2EaayF2OHxJlg89hN6BbHUiA0u7+TW7oW9E9c00cXhqanrZKbX6E1s8cNOOZJes uA4ZJfKU3F+Ro6btbOwjDZBLSLF3k925DWOa5HzjMnnwv9tx2wvDtpYmB9G4hNGXWzRE fPakqEtGLlUgXf7NyKRoq+wi/tHNJKGG3UUju1bdWUnxWVHn3sTrqUQDCug7lnHMSI89 Bu+A== X-Gm-Message-State: AGi0Pua0vsvDKSuOOse7W7kdDVERztNSbde+R4hoZq+CyTPSfmkDNAC6 kEtvAWKRnLbojfyjCNmp7F7KrocQdhrt0dLqSBiDpKxsMsk= X-Received: by 2002:a50:fa88:: with SMTP id w8mr617737edr.183.1586242705221; Mon, 06 Apr 2020 23:58:25 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Adrian Pop Date: Tue, 7 Apr 2020 09:58:14 +0300 Message-ID: Subject: Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs To: Angelo Ribeiro Cc: yannick.fertre@st.com, philippe.cornu@st.com, benjamin.gaignard@st.com, airlied@linux.ie, Daniel Vetter , mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, dri-devel@lists.freedesktop.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Gustavo Pimentel , Joao Pinto , Jose Abreu Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tested-by: Adrian Pop Tested OK on STM32F769i-DISCO, DSI v1.30, on next-20200406. On Mon, Apr 6, 2020 at 8:45 PM Adrian Pop wrote: > > Hello Angelo, > > Tested OK on STM32F769i-DISCO, DSI v1.30, on next-20200406. I guess > there is no horizontal for BER. > > Regards, > Adrian > > On Mon, Apr 6, 2020 at 4:49 PM Angelo Ribeiro > wrote: > > > > Add support for the video pattern generator (VPG) BER pattern mode and > > configuration in runtime. > > > > This enables using the debugfs interface to manipulate the VPG after > > the pipeline is set. > > Also, enables the usage of the VPG BER pattern. > > > > Changes in v2: > > - Added VID_MODE_VPG_MODE > > - Solved incompatible return type on __get and __set > > > > Reported-by: kbuild test robot > > Reported-by: Adrian Pop > > Cc: Gustavo Pimentel > > Cc: Joao Pinto > > Cc: Jose Abreu > > Signed-off-by: Angelo Ribeiro > > --- > > drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++--- > > 1 file changed, 90 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c > > index b18351b..9de3645 100644 > > --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c > > +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c > > @@ -91,6 +91,7 @@ > > #define VID_MODE_TYPE_BURST 0x2 > > #define VID_MODE_TYPE_MASK 0x3 > > #define VID_MODE_VPG_ENABLE BIT(16) > > +#define VID_MODE_VPG_MODE BIT(20) > > #define VID_MODE_VPG_HORIZONTAL BIT(24) > > > > #define DSI_VID_PKT_SIZE 0x3c > > @@ -221,6 +222,21 @@ > > #define PHY_STATUS_TIMEOUT_US 10000 > > #define CMD_PKT_STATUS_TIMEOUT_US 20000 > > > > +#ifdef CONFIG_DEBUG_FS > > +#define VPG_DEFS(name, dsi) \ > > + ((void __force *)&((*dsi).vpg_defs.name)) > > + > > +#define REGISTER(name, mask, dsi) \ > > + { #name, VPG_DEFS(name, dsi), mask, dsi } > > + > > +struct debugfs_entries { > > + const char *name; > > + bool *reg; > > + u32 mask; > > + struct dw_mipi_dsi *dsi; > > +}; > > +#endif /* CONFIG_DEBUG_FS */ > > + > > struct dw_mipi_dsi { > > struct drm_bridge bridge; > > struct mipi_dsi_host dsi_host; > > @@ -238,9 +254,12 @@ struct dw_mipi_dsi { > > > > #ifdef CONFIG_DEBUG_FS > > struct dentry *debugfs; > > - > > - bool vpg; > > - bool vpg_horizontal; > > + struct debugfs_entries *debugfs_vpg; > > + struct { > > + bool vpg; > > + bool vpg_horizontal; > > + bool vpg_ber_pattern; > > + } vpg_defs; > > #endif /* CONFIG_DEBUG_FS */ > > > > struct dw_mipi_dsi *master; /* dual-dsi master ptr */ > > @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi) > > val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS; > > > > #ifdef CONFIG_DEBUG_FS > > - if (dsi->vpg) { > > + if (dsi->vpg_defs.vpg) { > > val |= VID_MODE_VPG_ENABLE; > > - val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0; > > + val |= dsi->vpg_defs.vpg_horizontal ? > > + VID_MODE_VPG_HORIZONTAL : 0; > > + val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0; > > } > > #endif /* CONFIG_DEBUG_FS */ > > > > @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = { > > > > #ifdef CONFIG_DEBUG_FS > > > > +int dw_mipi_dsi_debugfs_write(void *data, u64 val) > > +{ > > + struct debugfs_entries *vpg = data; > > + struct dw_mipi_dsi *dsi; > > + u32 mode_cfg; > > + > > + if (!vpg) > > + return -ENODEV; > > + > > + dsi = vpg->dsi; > > + > > + *vpg->reg = (bool)val; > > + > > + mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG); > > + > > + if (*vpg->reg) > > + mode_cfg |= vpg->mask; > > + else > > + mode_cfg &= ~vpg->mask; > > + > > + dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg); > > + > > + return 0; > > +} > > + > > +int dw_mipi_dsi_debugfs_show(void *data, u64 *val) > > +{ > > + struct debugfs_entries *vpg = data; > > + > > + if (!vpg) > > + return -ENODEV; > > + > > + *val = *vpg->reg; > > + > > + return 0; > > +} > > + > > +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show, > > + dw_mipi_dsi_debugfs_write, "%llu\n"); > > + > > +static void debugfs_create_files(void *data) > > +{ > > + struct dw_mipi_dsi *dsi = data; > > + struct debugfs_entries debugfs[] = { > > + REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi), > > + REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi), > > + REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi), > > + }; > > + int i; > > + > > + dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL); > > + if (!dsi->debugfs_vpg) > > + return; > > + > > + memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs)); > > + > > + for (i = 0; i < ARRAY_SIZE(debugfs); i++) > > + debugfs_create_file(dsi->debugfs_vpg[i].name, 0644, > > + dsi->debugfs, &dsi->debugfs_vpg[i], > > + &fops_x32); > > +} > > + > > static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi) > > { > > dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL); > > @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi) > > return; > > } > > > > - debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg); > > - debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs, > > - &dsi->vpg_horizontal); > > + debugfs_create_files(dsi); > > } > > > > static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi) > > { > > debugfs_remove_recursive(dsi->debugfs); > > + kfree(dsi->debugfs_vpg); > > } > > > > #else > > -- > > 2.7.4 > >