Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 756c453a authored by Ajay Singh Parmar's avatar Ajay Singh Parmar
Browse files

drm/msm/dsi-staging: use parser APIs for custom panel data



In case custom panel data is used instead of device tree,
parse the data using parser sub-module and use its APIs instead
of device tree.

CRs-Fixed: 2223812
Change-Id: Id7d69d2ed35526e0c0e8e92739c85b9e22f4ab32
Signed-off-by: default avatarAjay Singh Parmar <aparmar@codeaurora.org>
parent 77e06261
Loading
Loading
Loading
Loading
+106 −18
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include "dsi_clk.h"
#include "dsi_pwr.h"
#include "sde_dbg.h"
#include "dsi_parser.h"

#define to_dsi_display(x) container_of(x, struct dsi_display, host)
#define INT_BASE_10 10
@@ -1143,6 +1144,8 @@ static int dsi_display_debugfs_init(struct dsi_display *display)
	}

	display->root = dir;
	dsi_parser_dbg_init(display->parser, dir);

	return rc;
error_remove_dir:
	debugfs_remove(dir);
@@ -2452,6 +2455,27 @@ static bool dsi_display_check_prefix(const char *clk_prefix,
	return !!strnstr(clk_name, clk_prefix, strlen(clk_name));
}

static int dsi_display_get_clocks_count(struct dsi_display *display)
{
	if (display->fw)
		return dsi_parser_count_strings(display->parser_node,
			"qcom,dsi-select-clocks");
	else
		return of_property_count_strings(display->disp_node,
			"qcom,dsi-select-clocks");
}

static void dsi_display_get_clock_name(struct dsi_display *display,
					int index, const char **clk_name)
{
	if (display->fw)
		dsi_parser_read_string_index(display->parser_node,
			"qcom,dsi-select-clocks", index, clk_name);
	else
		of_property_read_string_index(display->disp_node,
			"qcom,dsi-select-clocks", index, clk_name);
}

static int dsi_display_clocks_init(struct dsi_display *display)
{
	int i, rc = 0, num_clk = 0;
@@ -2464,12 +2488,12 @@ static int dsi_display_clocks_init(struct dsi_display *display)
	struct dsi_clk_link_set *mux = &display->clock_info.mux_clks;
	struct dsi_clk_link_set *shadow = &display->clock_info.shadow_clks;

	num_clk = of_property_count_strings(display->disp_node,
			"qcom,dsi-select-clocks");
	num_clk = dsi_display_get_clocks_count(display);

	pr_debug("clk count=%d\n", num_clk);

	for (i = 0; i < num_clk; i++) {
		of_property_read_string_index(display->disp_node,
			"qcom,dsi-select-clocks", i, &clk_name);
		dsi_display_get_clock_name(display, i, &clk_name);

		pr_debug("clock name:%s\n", clk_name);

@@ -2912,7 +2936,12 @@ static int dsi_display_get_phandle_index(
	if (index >= count)
		goto end;

	rc = of_property_read_u32_array(disp_node, propname, val, count);
	if (display->fw)
		rc = dsi_parser_read_u32_array(display->parser_node,
			propname, val, count);
	else
		rc = of_property_read_u32_array(disp_node, propname,
			val, count);
	if (rc)
		goto end;

@@ -2924,18 +2953,31 @@ static int dsi_display_get_phandle_index(
	return rc;
}

static int dsi_display_get_phandle_count(struct dsi_display *display,
			const char *propname)
{
	if (display->fw)
		return dsi_parser_count_u32_elems(display->parser_node,
				propname);
	else
		return of_property_count_u32_elems(display->disp_node,
				propname);
}

static int dsi_display_parse_dt(struct dsi_display *display)
{
	int rc = 0;
	int i;
	int i, rc = 0;
	u32 phy_count = 0;
	struct device_node *of_node = display->pdev->dev.of_node;
	struct device_node *disp_node = display->disp_node;

	display->ctrl_count = of_property_count_u32_elems(disp_node,
	display->ctrl_count = dsi_display_get_phandle_count(display,
				"qcom,dsi-ctrl-num");
	phy_count = dsi_display_get_phandle_count(display,
				"qcom,dsi-ctrl-num");
	phy_count = of_property_count_u32_elems(disp_node,
				"qcom,dsi-phy-num");

	pr_debug("ctrl count=%d, phy count=%d\n",
			display->ctrl_count, phy_count);

	if (!phy_count || !display->ctrl_count) {
		pr_err("no ctrl/phys found\n");
@@ -2972,6 +3014,8 @@ static int dsi_display_parse_dt(struct dsi_display *display)
		rc = -ENODEV;
		goto error;
	}

	pr_debug("success\n");
error:
	return rc;
}
@@ -3002,7 +3046,10 @@ static int dsi_display_res_init(struct dsi_display *display)
		}
	}

	display->panel = dsi_panel_get(&display->pdev->dev, display->panel_of,
	display->panel = dsi_panel_get(&display->pdev->dev,
				display->panel_of,
				display->parser_node,
				display->root,
				display->cmdline_topology);
	if (IS_ERR_OR_NULL(display->panel)) {
		rc = PTR_ERR(display->panel);
@@ -3489,6 +3536,12 @@ static int _dsi_display_dev_init(struct dsi_display *display)

	mutex_lock(&display->display_lock);

	display->parser = dsi_parser_get(&display->pdev->dev);
	if (display->fw && display->parser)
		display->parser_node = dsi_parser_get_head_node(
				display->parser, display->fw->data,
				display->fw->size);

	rc = dsi_display_parse_dt(display);
	if (rc) {
		pr_err("[%s] failed to parse dt, rc=%d\n", display->name, rc);
@@ -3968,6 +4021,28 @@ static int dsi_display_init(struct dsi_display *display,
	return rc;
}

static void dsi_display_firmware_display(const struct firmware *fw,
				void *context)
{
	struct dsi_display *display = context;
	struct platform_device *pdev = display->pdev;

	if (fw) {
		pr_debug("reading data from firmware, size=%zd\n",
			fw->size);

		display->fw = fw;
		display->name = "dsi_firmware_display";
	}

	dsi_display_setup(display);

	if (dsi_display_init(display, pdev))
		return;

	pr_debug("success\n");
}

int dsi_display_dev_probe(struct platform_device *pdev)
{
	struct dsi_display *display = NULL;
@@ -3976,6 +4051,7 @@ int dsi_display_dev_probe(struct platform_device *pdev)
	const char *disp_list = "qcom,dsi-display-list";
	const char *disp_active = "qcom,dsi-display-active";
	int i, count, rc = 0;
	bool firm_req = false;

	if (!pdev || !pdev->dev.of_node) {
		pr_err("pdev not found\n");
@@ -3984,8 +4060,10 @@ int dsi_display_dev_probe(struct platform_device *pdev)
	}

	display = devm_kzalloc(&pdev->dev, sizeof(*display), GFP_KERNEL);
	if (!display)
		return -ENOMEM;
	if (!display) {
		rc = -ENOMEM;
		goto end;
	}

	if (boot_displays[DSI_PRIMARY].boot_disp_en)
		display_from_cmdline = true;
@@ -4007,6 +4085,12 @@ int dsi_display_dev_probe(struct platform_device *pdev)
		} else {
			if (of_property_read_bool(np, disp_active)) {
				disp_node = np;

				if (IS_ENABLED(CONFIG_DSI_PARSER))
					firm_req = !request_firmware_nowait(
						THIS_MODULE, 1, "dsi_prop",
						&pdev->dev, GFP_KERNEL, display,
						dsi_display_firmware_display);
				break;
			}
		}
@@ -4030,10 +4114,14 @@ int dsi_display_dev_probe(struct platform_device *pdev)
	platform_set_drvdata(pdev, display);
	default_display = display;

	/* initialize display in firmware callback */
	if (!firm_req) {
		dsi_display_setup(display);

		rc = dsi_display_init(display, pdev);
		if (rc)
			goto end;
	}

	return 0;
end:
+6 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <linux/bitops.h>
#include <linux/debugfs.h>
#include <linux/of_device.h>
#include <linux/firmware.h>
#include <drm/drmP.h>
#include <drm/drm_crtc.h>

@@ -181,6 +182,7 @@ struct dsi_display {
	struct dsi_panel *panel;
	struct device_node *disp_node;
	struct device_node *panel_of;
	struct device_node *parser_node;

	struct dsi_display_mode *modes;

@@ -226,6 +228,10 @@ struct dsi_display {
	struct work_struct fifo_underflow_work;
	struct work_struct fifo_overflow_work;
	struct work_struct lp_rx_timeout_work;

	/* firmware panel data */
	const struct firmware *fw;
	void *parser;
};

int dsi_display_dev_probe(struct platform_device *pdev);
Loading