lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <A3089DC4F031A2C0+aKLcKYtWzpLdB0lH@LT-Guozexi>
Date: Mon, 18 Aug 2025 15:54:17 +0800
From: Troy Mitchell <troy.mitchell@...ux.spacemit.com>
To: Icenowy Zheng <uwu@...nowy.me>,
	Troy Mitchell <troy.mitchell@...ux.spacemit.com>,
	Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>
Cc: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
	Maxime Ripard <mripard@...nel.org>,
	Thomas Zimmermann <tzimmermann@...e.de>,
	David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
	Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzk+dt@...nel.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Drew Fustini <fustini@...nel.org>, Guo Ren <guoren@...nel.org>,
	Fu Wei <wefu@...hat.com>, Philipp Zabel <p.zabel@...gutronix.de>,
	Heiko Stuebner <heiko@...ech.de>,
	Andrzej Hajda <andrzej.hajda@...el.com>,
	Neil Armstrong <neil.armstrong@...aro.org>,
	Robert Foss <rfoss@...nel.org>,
	Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
	Jonas Karlman <jonas@...boo.se>,
	Jernej Skrabec <jernej.skrabec@...il.com>,
	Michal Wilczynski <m.wilczynski@...sung.com>,
	Han Gao <rabenda.cn@...il.com>, Yao Zi <ziyao@...root.org>,
	dri-devel@...ts.freedesktop.org, devicetree@...r.kernel.org,
	linux-kernel@...r.kernel.org, linux-riscv@...ts.infradead.org
Subject: Re: [RFC PATCH 5/8] drm/bridge: add a driver for T-Head TH1520 HDMI
 controller

On Mon, Aug 18, 2025 at 03:47:28PM +0800, Icenowy Zheng wrote:
> 在 2025-08-18星期一的 15:45 +0800,Troy Mitchell写道:
> > On Sun, Aug 17, 2025 at 01:10:44AM +0800, Icenowy Zheng wrote:
> > > 在 2025-08-16星期六的 19:24 +0300,Dmitry Baryshkov写道:
> > > > On Fri, Aug 15, 2025 at 12:40:45AM +0800, Icenowy Zheng wrote:
> > > > > T-Head TH1520 SoC contains a Synopsys DesignWare HDMI
> > > > > controller
> > > > > (paired
> > > > > with DesignWare HDMI TX PHY Gen2) that takes the "DP" output
> > > > > from
> > > > > the
> > > > > display controller.
> > > > > 
> > > > > Add a driver for this controller utilizing the common
> > > > > DesignWare
> > > > > HDMI
> > > > > code in the kernel.
> > > > > 
> > > > > Signed-off-by: Icenowy Zheng <uwu@...nowy.me>
> > > > > ---
[...]
> > > > > +static int th1520_hdmi_phy_configure(struct dw_hdmi *hdmi,
> > > > > void
> > > > > *data,
> > > > > +                                    unsigned long mpixelclock)
> > > > > +{
> > > > > +       const struct th1520_hdmi_phy_params *params =
> > > > > th1520_hdmi_phy_params;
> > > > > +
> > > > > +       for (; params->mpixelclock != ~0UL; ++params) {
> > > > > +               if (mpixelclock <= params->mpixelclock)
> > > > > +                       break;
> > > > 
> > > > for (...) {
> > > >         if (mpixelclock <= params->mpixelclock)
> > > >                 return th1520_program_phy();
> > > 
> > > There's no such a function here, and this check isn't used for
> > > another
> > > time, so having the matching code and programming code extracted
> > > out
> > > can help nothing.
> > I think Dmitry meant that the following code should be moved into
> > a new function, th1520_program_phy().  
> > 
> > This makes the code cleaner and also avoids one extra if check.
> 
> As there's no code reuse, it does not make code cleaner.
I respect your opinion, but let's also see what Dmitry has to say.

                - Troy
> 
> > 
> >                 - Troy
> > > 
> > > > }
> > > > 
> > > > return -EINVAL;
> > > > 
> > > > > +       }
> > > > > +
> > > > > +       if (params->mpixelclock == ~0UL)
> > > > > +               return -EINVAL;
> > > > > +
> > > > > +       dw_hdmi_phy_i2c_write(hdmi, params->opmode_pllcfg,
> > > > > +                             TH1520_HDMI_PHY_OPMODE_PLLCFG);
> > > > > +       dw_hdmi_phy_i2c_write(hdmi, params->pllcurrgmpctrl,
> > > > > +                             TH1520_HDMI_PHY_PLLCURRGMPCTRL);
> > > > > +       dw_hdmi_phy_i2c_write(hdmi, params->plldivctrl,
> > > > > +                             TH1520_HDMI_PHY_PLLDIVCTRL);
> > > > > +       dw_hdmi_phy_i2c_write(hdmi, params->vlevctrl,
> > > > > +                             TH1520_HDMI_PHY_VLEVCTRL);
> > > > > +       dw_hdmi_phy_i2c_write(hdmi, params->cksymtxctrl,
> > > > > +                             TH1520_HDMI_PHY_CKSYMTXCTRL);
> > > > > +       dw_hdmi_phy_i2c_write(hdmi, params->txterm,
> > > > > +                             TH1520_HDMI_PHY_TXTERM);
> > > > > +
> > > > > +       return 0;
> > > > > +}
> > > > > +
> > > > > +static int th1520_dw_hdmi_probe(struct platform_device *pdev)
> > > > > +{
> > > > > +       struct th1520_hdmi *hdmi;
> > > > > +       struct dw_hdmi_plat_data *plat_data;
> > > > > +       struct device *dev = &pdev->dev;
> > > > > +
> > > > > +       hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
> > > > > +       if (!hdmi)
> > > > > +               return -ENOMEM;
> > > > > +
> > > > > +       plat_data = &hdmi->plat_data;
> > > > > +
> > > > > +       hdmi->pixclk = devm_clk_get_enabled(dev, "pix");
> > > > > +       if (IS_ERR(hdmi->pixclk))
> > > > > +               return dev_err_probe(dev, PTR_ERR(hdmi-
> > > > > >pixclk),
> > > > > +                                    "Unable to get pixel
> > > > > clock\n");
> > > > > +
> > > > > +       hdmi->mainrst =
> > > > > devm_reset_control_get_exclusive_deasserted(dev, "main");
> > > > > +       if (IS_ERR(hdmi->mainrst))
> > > > > +               return dev_err_probe(dev, PTR_ERR(hdmi-
> > > > > >mainrst),
> > > > > +                                    "Unable to get main
> > > > > reset\n");
> > > > > +
> > > > > +       hdmi->prst =
> > > > > devm_reset_control_get_exclusive_deasserted(dev, "apb");
> > > > > +       if (IS_ERR(hdmi->prst))
> > > > > +               return dev_err_probe(dev, PTR_ERR(hdmi->prst),
> > > > > +                                    "Unable to get apb
> > > > > reset\n");
> > > > > +
> > > > > +       plat_data->output_port = 1;
> > > > > +       plat_data->mode_valid = th1520_hdmi_mode_valid;
> > > > > +       plat_data->configure_phy = th1520_hdmi_phy_configure;
> > > > > +       plat_data->priv_data = hdmi;
> > > > > +
> > > > > +       hdmi->dw_hdmi = dw_hdmi_probe(pdev, plat_data);
> > > > > +       if (IS_ERR(hdmi))
> > > > > +               return PTR_ERR(hdmi);
> > > > > +
> > > > > +       platform_set_drvdata(pdev, hdmi);
> > > > > +
> > > > > +       return 0;
> > > > > +}
> > > > > +
> > > > > +static void th1520_dw_hdmi_remove(struct platform_device
> > > > > *pdev)
> > > > > +{
> > > > > +       struct dw_hdmi *hdmi = platform_get_drvdata(pdev);
> > > > > +
> > > > > +       dw_hdmi_remove(hdmi);
> > > > > +}
> > > > > +
> > > > > +static const struct of_device_id th1520_dw_hdmi_of_table[] = {
> > > > > +       { .compatible = "thead,th1520-dw-hdmi" },
> > > > > +       { /* Sentinel */ },
> > > > > +};
> > > > > +MODULE_DEVICE_TABLE(of, th1520_dw_hdmi_of_table);
> > > > > +
> > > > > +static struct platform_driver th1520_dw_hdmi_platform_driver =
> > > > > {
> > > > > +       .probe          = th1520_dw_hdmi_probe,
> > > > > +       .remove         = th1520_dw_hdmi_remove,
> > > > > +       .driver         = {
> > > > > +               .name   = "th1520-dw-hdmi",
> > > > > +               .of_match_table = th1520_dw_hdmi_of_table,
> > > > > +       },
> > > > > +};
> > > > > +
> > > > > +module_platform_driver(th1520_dw_hdmi_platform_driver);
> > > > > +
> > > > > +MODULE_AUTHOR("Icenowy Zheng <uwu@...nowy.me>");
> > > > > +MODULE_DESCRIPTION("T-Head TH1520 HDMI Encoder Driver");
> > > > > +MODULE_LICENSE("GPL");
> > > > > -- 
> > > > > 2.50.1
> > > > > 
> > > > 
> > > 
> > > _______________________________________________
> > > linux-riscv mailing list
> > > linux-riscv@...ts.infradead.org
> > > http://lists.infradead.org/mailman/listinfo/linux-riscv
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ