[PATCH 25/48] drm: omapdrm: dss: Pass DSS pointer to dss_ops operations
Sebastian Reichel
sre at kernel.org
Mon Oct 16 09:05:50 UTC 2017
Hi,
On Fri, Oct 13, 2017 at 05:59:21PM +0300, Laurent Pinchart wrote:
> This removes the need to access the global DSS private data in those
> functions (both for the current accesses and the future ones that will
> be introduced when allocating the DSS device dynamically).
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
Reviewed-by: Sebastian Reichel <sebastian.reichel at collabora.co.uk>
-- Sebastian
> drivers/gpu/drm/omapdrm/dss/dpi.c | 12 ++++---
> drivers/gpu/drm/omapdrm/dss/dsi.c | 18 +++++-----
> drivers/gpu/drm/omapdrm/dss/dss.c | 68 ++++++++++++++++++++++---------------
> drivers/gpu/drm/omapdrm/dss/dss.h | 25 ++++++++------
> drivers/gpu/drm/omapdrm/dss/hdmi.h | 1 +
> drivers/gpu/drm/omapdrm/dss/hdmi4.c | 3 +-
> drivers/gpu/drm/omapdrm/dss/hdmi5.c | 3 +-
> 7 files changed, 77 insertions(+), 53 deletions(-)
>
> diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
> index c7346df60929..38a4c037783a 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dpi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
> @@ -40,6 +40,7 @@
> struct dpi_data {
> struct platform_device *pdev;
> enum dss_model dss_model;
> + struct dss_device *dss;
>
> struct regulator *vdds_dsi_reg;
> enum dss_clk_source clk_src;
> @@ -304,7 +305,7 @@ static int dpi_set_pll_clk(struct dpi_data *dpi, enum omap_channel channel,
> if (r)
> return r;
>
> - dss_select_lcd_clk_source(channel, dpi->clk_src);
> + dss_select_lcd_clk_source(dpi->dss, channel, dpi->clk_src);
>
> dpi->mgr_config.clock_info = ctx.dispc_cinfo;
>
> @@ -414,7 +415,7 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
> if (r)
> goto err_get_dispc;
>
> - r = dss_dpi_select_source(out->port_num, channel);
> + r = dss_dpi_select_source(dpi->dss, out->port_num, channel);
> if (r)
> goto err_src_sel;
>
> @@ -466,7 +467,7 @@ static void dpi_display_disable(struct omap_dss_device *dssdev)
> dss_mgr_disable(channel);
>
> if (dpi->pll) {
> - dss_select_lcd_clk_source(channel, DSS_CLK_SRC_FCK);
> + dss_select_lcd_clk_source(dpi->dss, channel, DSS_CLK_SRC_FCK);
> dss_pll_disable(dpi->pll);
> }
>
> @@ -750,8 +751,8 @@ static void dpi_uninit_output_port(struct device_node *port)
> omapdss_unregister_output(out);
> }
>
> -int dpi_init_port(struct platform_device *pdev, struct device_node *port,
> - enum dss_model dss_model)
> +int dpi_init_port(struct dss_device *dss, struct platform_device *pdev,
> + struct device_node *port, enum dss_model dss_model)
> {
> struct dpi_data *dpi;
> struct device_node *ep;
> @@ -778,6 +779,7 @@ int dpi_init_port(struct platform_device *pdev, struct device_node *port,
>
> dpi->pdev = pdev;
> dpi->dss_model = dss_model;
> + dpi->dss = dss;
> port->data = dpi;
>
> mutex_init(&dpi->lock);
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 1dab308c9bc1..6d60882dfd10 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -345,6 +345,7 @@ struct dsi_data {
>
> struct clk *dss_clk;
> struct regmap *syscon;
> + struct dss_device *dss;
>
> struct dispc_clock_info user_dispc_cinfo;
> struct dss_pll_clock_info user_dsi_cinfo;
> @@ -4217,7 +4218,7 @@ static int dsi_display_init_dispc(struct platform_device *dsidev,
> struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> int r;
>
> - dss_select_lcd_clk_source(channel, dsi->module_id == 0 ?
> + dss_select_lcd_clk_source(dsi->dss, channel, dsi->module_id == 0 ?
> DSS_CLK_SRC_PLL1_1 :
> DSS_CLK_SRC_PLL2_1);
>
> @@ -4271,7 +4272,7 @@ static int dsi_display_init_dispc(struct platform_device *dsidev,
> dss_mgr_unregister_framedone_handler(channel,
> dsi_framedone_irq_callback, dsidev);
> err:
> - dss_select_lcd_clk_source(channel, DSS_CLK_SRC_FCK);
> + dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
> return r;
> }
>
> @@ -4284,7 +4285,7 @@ static void dsi_display_uninit_dispc(struct platform_device *dsidev,
> dss_mgr_unregister_framedone_handler(channel,
> dsi_framedone_irq_callback, dsidev);
>
> - dss_select_lcd_clk_source(channel, DSS_CLK_SRC_FCK);
> + dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
> }
>
> static int dsi_configure_dsi_clocks(struct platform_device *dsidev)
> @@ -4317,9 +4318,9 @@ static int dsi_display_init_dsi(struct platform_device *dsidev)
> if (r)
> goto err1;
>
> - dss_select_dsi_clk_source(dsi->module_id, dsi->module_id == 0 ?
> - DSS_CLK_SRC_PLL1_2 :
> - DSS_CLK_SRC_PLL2_2);
> + dss_select_dsi_clk_source(dsi->dss, dsi->module_id,
> + dsi->module_id == 0 ?
> + DSS_CLK_SRC_PLL1_2 : DSS_CLK_SRC_PLL2_2);
>
> DSSDBG("PLL OK\n");
>
> @@ -4351,7 +4352,7 @@ static int dsi_display_init_dsi(struct platform_device *dsidev)
> err3:
> dsi_cio_uninit(dsidev);
> err2:
> - dss_select_dsi_clk_source(dsi->module_id, DSS_CLK_SRC_FCK);
> + dss_select_dsi_clk_source(dsi->dss, dsi->module_id, DSS_CLK_SRC_FCK);
> err1:
> dss_pll_disable(&dsi->pll);
> err0:
> @@ -4373,7 +4374,7 @@ static void dsi_display_uninit_dsi(struct platform_device *dsidev,
> dsi_vc_enable(dsidev, 2, 0);
> dsi_vc_enable(dsidev, 3, 0);
>
> - dss_select_dsi_clk_source(dsi->module_id, DSS_CLK_SRC_FCK);
> + dss_select_dsi_clk_source(dsi->dss, dsi->module_id, DSS_CLK_SRC_FCK);
> dsi_cio_uninit(dsidev);
> dsi_pll_uninit(dsidev, disconnect_lanes);
> }
> @@ -5443,6 +5444,7 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
> if (!dsi)
> return -ENOMEM;
>
> + dsi->dss = dss;
> dsi->pdev = dsidev;
> dev_set_drvdata(&dsidev->dev, dsi);
>
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index f8b71e24a07d..bd8f7abf0450 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -74,9 +74,11 @@ struct dss_reg {
> dss_write_reg(idx, FLD_MOD(dss_read_reg(idx), val, start, end))
>
> struct dss_ops {
> - int (*dpi_select_source)(int port, enum omap_channel channel);
> - int (*select_lcd_source)(enum omap_channel channel,
> - enum dss_clk_source clk_src);
> + int (*dpi_select_source)(struct dss_device *dss, int port,
> + enum omap_channel channel);
> + int (*select_lcd_source)(struct dss_device *dss,
> + enum omap_channel channel,
> + enum dss_clk_source clk_src);
> };
>
> struct dss_features {
> @@ -472,8 +474,8 @@ static void dss_select_dispc_clk_source(enum dss_clk_source clk_src)
> dss.dispc_clk_source = clk_src;
> }
>
> -void dss_select_dsi_clk_source(int dsi_module,
> - enum dss_clk_source clk_src)
> +void dss_select_dsi_clk_source(struct dss_device *dss, int dsi_module,
> + enum dss_clk_source clk_src)
> {
> int b, pos;
>
> @@ -497,11 +499,12 @@ void dss_select_dsi_clk_source(int dsi_module,
> pos = dsi_module == 0 ? 1 : 10;
> REG_FLD_MOD(DSS_CONTROL, b, pos, pos); /* DSIx_CLK_SWITCH */
>
> - dss.dsi_clk_source[dsi_module] = clk_src;
> + dss->dsi_clk_source[dsi_module] = clk_src;
> }
>
> -static int dss_lcd_clk_mux_dra7(enum omap_channel channel,
> - enum dss_clk_source clk_src)
> +static int dss_lcd_clk_mux_dra7(struct dss_device *dss,
> + enum omap_channel channel,
> + enum dss_clk_source clk_src)
> {
> const u8 ctrl_bits[] = {
> [OMAP_DSS_CHANNEL_LCD] = 0,
> @@ -527,8 +530,9 @@ static int dss_lcd_clk_mux_dra7(enum omap_channel channel,
> return 0;
> }
>
> -static int dss_lcd_clk_mux_omap5(enum omap_channel channel,
> - enum dss_clk_source clk_src)
> +static int dss_lcd_clk_mux_omap5(struct dss_device *dss,
> + enum omap_channel channel,
> + enum dss_clk_source clk_src)
> {
> const u8 ctrl_bits[] = {
> [OMAP_DSS_CHANNEL_LCD] = 0,
> @@ -557,8 +561,9 @@ static int dss_lcd_clk_mux_omap5(enum omap_channel channel,
> return 0;
> }
>
> -static int dss_lcd_clk_mux_omap4(enum omap_channel channel,
> - enum dss_clk_source clk_src)
> +static int dss_lcd_clk_mux_omap4(struct dss_device *dss,
> + enum omap_channel channel,
> + enum dss_clk_source clk_src)
> {
> const u8 ctrl_bits[] = {
> [OMAP_DSS_CHANNEL_LCD] = 0,
> @@ -585,23 +590,24 @@ static int dss_lcd_clk_mux_omap4(enum omap_channel channel,
> return 0;
> }
>
> -void dss_select_lcd_clk_source(enum omap_channel channel,
> - enum dss_clk_source clk_src)
> +void dss_select_lcd_clk_source(struct dss_device *dss,
> + enum omap_channel channel,
> + enum dss_clk_source clk_src)
> {
> int idx = dss_get_channel_index(channel);
> int r;
>
> - if (!dss.feat->has_lcd_clk_src) {
> + if (!dss->feat->has_lcd_clk_src) {
> dss_select_dispc_clk_source(clk_src);
> - dss.lcd_clk_source[idx] = clk_src;
> + dss->lcd_clk_source[idx] = clk_src;
> return;
> }
>
> - r = dss.feat->ops->select_lcd_source(channel, clk_src);
> + r = dss->feat->ops->select_lcd_source(dss, channel, clk_src);
> if (r)
> return;
>
> - dss.lcd_clk_source[idx] = clk_src;
> + dss->lcd_clk_source[idx] = clk_src;
> }
>
> enum dss_clk_source dss_get_dispc_clk_source(void)
> @@ -750,11 +756,12 @@ void dss_set_dac_pwrdn_bgz(bool enable)
> REG_FLD_MOD(DSS_CONTROL, enable, 5, 5); /* DAC Power-Down Control */
> }
>
> -void dss_select_hdmi_venc_clk_source(enum dss_hdmi_venc_clk_source_select src)
> +void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
> + enum dss_hdmi_venc_clk_source_select src)
> {
> enum omap_dss_output_id outputs;
>
> - outputs = dss.feat->outputs[OMAP_DSS_CHANNEL_DIGIT];
> + outputs = dss->feat->outputs[OMAP_DSS_CHANNEL_DIGIT];
>
> /* Complain about invalid selections */
> WARN_ON((src == DSS_VENC_TV_CLK) && !(outputs & OMAP_DSS_OUTPUT_VENC));
> @@ -780,7 +787,8 @@ enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void)
> return REG_GET(DSS_CONTROL, 15, 15);
> }
>
> -static int dss_dpi_select_source_omap2_omap3(int port, enum omap_channel channel)
> +static int dss_dpi_select_source_omap2_omap3(struct dss_device *dss, int port,
> + enum omap_channel channel)
> {
> if (channel != OMAP_DSS_CHANNEL_LCD)
> return -EINVAL;
> @@ -788,7 +796,8 @@ static int dss_dpi_select_source_omap2_omap3(int port, enum omap_channel channel
> return 0;
> }
>
> -static int dss_dpi_select_source_omap4(int port, enum omap_channel channel)
> +static int dss_dpi_select_source_omap4(struct dss_device *dss, int port,
> + enum omap_channel channel)
> {
> int val;
>
> @@ -808,7 +817,8 @@ static int dss_dpi_select_source_omap4(int port, enum omap_channel channel)
> return 0;
> }
>
> -static int dss_dpi_select_source_omap5(int port, enum omap_channel channel)
> +static int dss_dpi_select_source_omap5(struct dss_device *dss, int port,
> + enum omap_channel channel)
> {
> int val;
>
> @@ -834,11 +844,12 @@ static int dss_dpi_select_source_omap5(int port, enum omap_channel channel)
> return 0;
> }
>
> -static int dss_dpi_select_source_dra7xx(int port, enum omap_channel channel)
> +static int dss_dpi_select_source_dra7xx(struct dss_device *dss, int port,
> + enum omap_channel channel)
> {
> switch (port) {
> case 0:
> - return dss_dpi_select_source_omap5(port, channel);
> + return dss_dpi_select_source_omap5(dss, port, channel);
> case 1:
> if (channel != OMAP_DSS_CHANNEL_LCD2)
> return -EINVAL;
> @@ -854,9 +865,10 @@ static int dss_dpi_select_source_dra7xx(int port, enum omap_channel channel)
> return 0;
> }
>
> -int dss_dpi_select_source(int port, enum omap_channel channel)
> +int dss_dpi_select_source(struct dss_device *dss, int port,
> + enum omap_channel channel)
> {
> - return dss.feat->ops->dpi_select_source(port, channel);
> + return dss->feat->ops->dpi_select_source(dss, port, channel);
> }
>
> static int dss_get_clocks(void)
> @@ -1223,7 +1235,7 @@ static int dss_init_ports(struct platform_device *pdev)
>
> switch (dss.feat->ports[i]) {
> case OMAP_DISPLAY_TYPE_DPI:
> - dpi_init_port(pdev, port, dss.feat->model);
> + dpi_init_port(&dss, pdev, port, dss.feat->model);
> break;
> case OMAP_DISPLAY_TYPE_SDI:
> sdi_init_port(&dss, pdev, port);
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index 08651f101518..05fba6b3400b 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -287,8 +287,10 @@ void dss_runtime_put(struct dss_device *dss);
> unsigned long dss_get_dispc_clk_rate(void);
> unsigned long dss_get_max_fck_rate(void);
> enum omap_dss_output_id dss_get_supported_outputs(enum omap_channel channel);
> -int dss_dpi_select_source(int port, enum omap_channel channel);
> -void dss_select_hdmi_venc_clk_source(enum dss_hdmi_venc_clk_source_select);
> +int dss_dpi_select_source(struct dss_device *dss, int port,
> + enum omap_channel channel);
> +void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
> + enum dss_hdmi_venc_clk_source_select src);
> enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void);
> const char *dss_get_clk_source_name(enum dss_clk_source clk_src);
>
> @@ -304,10 +306,11 @@ void dss_sdi_init(struct dss_device *dss, int datapairs);
> int dss_sdi_enable(struct dss_device *dss);
> void dss_sdi_disable(struct dss_device *dss);
>
> -void dss_select_dsi_clk_source(int dsi_module,
> - enum dss_clk_source clk_src);
> -void dss_select_lcd_clk_source(enum omap_channel channel,
> - enum dss_clk_source clk_src);
> +void dss_select_dsi_clk_source(struct dss_device *dss, int dsi_module,
> + enum dss_clk_source clk_src);
> +void dss_select_lcd_clk_source(struct dss_device *dss,
> + enum omap_channel channel,
> + enum dss_clk_source clk_src);
> enum dss_clk_source dss_get_dispc_clk_source(void);
> enum dss_clk_source dss_get_dsi_clk_source(int dsi_module);
> enum dss_clk_source dss_get_lcd_clk_source(enum omap_channel channel);
> @@ -353,12 +356,14 @@ void dsi_irq_handler(void);
>
> /* DPI */
> #ifdef CONFIG_OMAP2_DSS_DPI
> -int dpi_init_port(struct platform_device *pdev, struct device_node *port,
> - enum dss_model dss_model);
> +int dpi_init_port(struct dss_device *dss, struct platform_device *pdev,
> + struct device_node *port, enum dss_model dss_model);
> void dpi_uninit_port(struct device_node *port);
> #else
> -static inline int dpi_init_port(struct platform_device *pdev,
> - struct device_node *port, enum dss_model dss_model)
> +static inline int dpi_init_port(struct dss_device *port,
> + struct platform_device *pdev,
> + struct device_node *port,
> + enum dss_model dss_model)
> {
> return 0;
> }
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h b/drivers/gpu/drm/omapdrm/dss/hdmi.h
> index 4dbc4f3d728c..fa2fbdaa427c 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi.h
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h
> @@ -359,6 +359,7 @@ static inline bool hdmi_mode_has_audio(struct hdmi_config *cfg)
> struct omap_hdmi {
> struct mutex lock;
> struct platform_device *pdev;
> + struct dss_device *dss;
>
> struct dss_debugfs_entry *debugfs;
>
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> index d84eba8440c8..5806587fd89a 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> @@ -147,7 +147,7 @@ static int hdmi_power_on_core(struct omap_dss_device *dssdev)
> hdmi4_core_powerdown_disable(&hdmi.core);
>
> /* Make selection of HDMI in DSS */
> - dss_select_hdmi_venc_clk_source(DSS_HDMI_M_PCLK);
> + dss_select_hdmi_venc_clk_source(hdmi.dss, DSS_HDMI_M_PCLK);
>
> hdmi.core_enabled = true;
>
> @@ -722,6 +722,7 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data)
> int irq;
>
> hdmi.pdev = pdev;
> + hdmi.dss = dss;
> dev_set_drvdata(&pdev->dev, &hdmi);
>
> mutex_init(&hdmi.lock);
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> index 64cfed89c79b..c28fe184a7ad 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> @@ -149,7 +149,7 @@ static int hdmi_power_on_core(struct omap_dss_device *dssdev)
> goto err_runtime_get;
>
> /* Make selection of HDMI in DSS */
> - dss_select_hdmi_venc_clk_source(DSS_HDMI_M_PCLK);
> + dss_select_hdmi_venc_clk_source(hdmi.dss, DSS_HDMI_M_PCLK);
>
> hdmi.core_enabled = true;
>
> @@ -724,6 +724,7 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data)
> int irq;
>
> hdmi.pdev = pdev;
> + hdmi.dss = dss;
> dev_set_drvdata(&pdev->dev, &hdmi);
>
> mutex_init(&hdmi.lock);
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20171016/539d14a5/attachment-0001.sig>
More information about the dri-devel
mailing list