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);
+271 −212

File changed.

Preview size limit exceeded, changes collapsed.

+7 −2
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include "dsi_ctrl_hw.h"
#include "dsi_clk.h"
#include "dsi_pwr.h"
#include "dsi_parser.h"
#include "msm_drv.h"

#define MAX_BL_LEVEL 4096
@@ -149,6 +150,7 @@ struct dsi_panel {
	struct drm_panel drm_panel;
	struct mipi_dsi_host *host;
	struct device *parent;
	struct dentry *root;

	struct dsi_host_common_cfg host_config;
	struct dsi_video_engine_cfg video_config;
@@ -168,6 +170,8 @@ struct dsi_panel {
	struct drm_panel_hdr_properties hdr_props;
	struct drm_panel_esd_config esd_config;

	struct dsi_parser_utils utils;

	bool lp11_init;
	bool ulps_enabled;
	bool ulps_suspend_enabled;
@@ -204,6 +208,8 @@ static inline void dsi_panel_release_panel_lock(struct dsi_panel *panel)

struct dsi_panel *dsi_panel_get(struct device *parent,
				struct device_node *of_node,
				struct device_node *parser_node,
				struct dentry *root,
				int topology_override);

int dsi_panel_trigger_esd_attack(struct dsi_panel *panel);
@@ -214,8 +220,7 @@ int dsi_panel_drv_init(struct dsi_panel *panel, struct mipi_dsi_host *host);

int dsi_panel_drv_deinit(struct dsi_panel *panel);

int dsi_panel_get_mode_count(struct dsi_panel *panel,
		struct device_node *of_node);
int dsi_panel_get_mode_count(struct dsi_panel *panel);

void dsi_panel_put_mode(struct dsi_display_mode *mode);

+25 −26
Original line number Diff line number Diff line
@@ -17,11 +17,13 @@
#include <linux/slab.h>

#include "dsi_pwr.h"
#include "dsi_parser.h"

/*
 * dsi_pwr_parse_supply_node() - parse power supply node from root device node
 */
static int dsi_pwr_parse_supply_node(struct device_node *root,
static int dsi_pwr_parse_supply_node(struct dsi_parser_utils *utils,
				     struct device_node *root,
				     struct dsi_regulator_info *regs)
{
	int rc = 0;
@@ -29,10 +31,10 @@ static int dsi_pwr_parse_supply_node(struct device_node *root,
	u32 tmp = 0;
	struct device_node *node = NULL;

	for_each_child_of_node(root, node) {
	dsi_for_each_child_node(root, node) {
		const char *st = NULL;

		rc = of_property_read_string(node, "qcom,supply-name", &st);
		rc = utils->read_string(node, "qcom,supply-name", &st);
		if (rc) {
			pr_err("failed to read name, rc = %d\n", rc);
			goto error;
@@ -42,32 +44,28 @@ static int dsi_pwr_parse_supply_node(struct device_node *root,
			 ARRAY_SIZE(regs->vregs[i].vreg_name),
			 "%s", st);

		rc = of_property_read_u32(node, "qcom,supply-min-voltage",
					  &tmp);
		rc = utils->read_u32(node, "qcom,supply-min-voltage", &tmp);
		if (rc) {
			pr_err("failed to read min voltage, rc = %d\n", rc);
			goto error;
		}
		regs->vregs[i].min_voltage = tmp;

		rc = of_property_read_u32(node, "qcom,supply-max-voltage",
					  &tmp);
		rc = utils->read_u32(node, "qcom,supply-max-voltage", &tmp);
		if (rc) {
			pr_err("failed to read max voltage, rc = %d\n", rc);
			goto error;
		}
		regs->vregs[i].max_voltage = tmp;

		rc = of_property_read_u32(node, "qcom,supply-enable-load",
					  &tmp);
		rc = utils->read_u32(node, "qcom,supply-enable-load", &tmp);
		if (rc) {
			pr_err("failed to read enable load, rc = %d\n", rc);
			goto error;
		}
		regs->vregs[i].enable_load = tmp;

		rc = of_property_read_u32(node, "qcom,supply-disable-load",
					  &tmp);
		rc = utils->read_u32(node, "qcom,supply-disable-load", &tmp);
		if (rc) {
			pr_err("failed to read disable load, rc = %d\n", rc);
			goto error;
@@ -75,8 +73,7 @@ static int dsi_pwr_parse_supply_node(struct device_node *root,
		regs->vregs[i].disable_load = tmp;

		/* Optional values */
		rc = of_property_read_u32(node, "qcom,supply-pre-on-sleep",
					  &tmp);
		rc = utils->read_u32(node, "qcom,supply-pre-on-sleep", &tmp);
		if (rc) {
			pr_debug("pre-on-sleep not specified\n");
			rc = 0;
@@ -84,8 +81,7 @@ static int dsi_pwr_parse_supply_node(struct device_node *root,
			regs->vregs[i].pre_on_sleep = tmp;
		}

		rc = of_property_read_u32(node, "qcom,supply-pre-off-sleep",
					  &tmp);
		rc = utils->read_u32(node, "qcom,supply-pre-off-sleep", &tmp);
		if (rc) {
			pr_debug("pre-off-sleep not specified\n");
			rc = 0;
@@ -93,8 +89,7 @@ static int dsi_pwr_parse_supply_node(struct device_node *root,
			regs->vregs[i].pre_off_sleep = tmp;
		}

		rc = of_property_read_u32(node, "qcom,supply-post-on-sleep",
					  &tmp);
		rc = utils->read_u32(node, "qcom,supply-post-on-sleep", &tmp);
		if (rc) {
			pr_debug("post-on-sleep not specified\n");
			rc = 0;
@@ -102,8 +97,7 @@ static int dsi_pwr_parse_supply_node(struct device_node *root,
			regs->vregs[i].post_on_sleep = tmp;
		}

		rc = of_property_read_u32(node, "qcom,supply-post-off-sleep",
					  &tmp);
		rc = utils->read_u32(node, "qcom,supply-post-off-sleep", &tmp);
		if (rc) {
			pr_debug("post-off-sleep not specified\n");
			rc = 0;
@@ -221,22 +215,23 @@ static int dsi_pwr_enable_vregs(struct dsi_regulator_info *regs, bool enable)
 *
 * return: error code in case of failure or 0 for success.
 */
int dsi_pwr_of_get_vreg_data(struct device_node *of_node,
int dsi_pwr_of_get_vreg_data(struct dsi_parser_utils *utils,
				 struct dsi_regulator_info *regs,
				 char *supply_name)
{
	int rc = 0;
	struct device_node *supply_root_node = NULL;

	if (!of_node || !regs) {
	if (!utils || !regs) {
		pr_err("Bad params\n");
		return -EINVAL;
	}

	regs->count = 0;
	supply_root_node = of_get_child_by_name(of_node, supply_name);
	supply_root_node = utils->get_child_by_name(utils->data, supply_name);
	if (!supply_root_node) {
		supply_root_node = of_parse_phandle(of_node, supply_name, 0);
		supply_root_node = of_parse_phandle(utils->node,
					supply_name, 0);
		if (!supply_root_node) {
			pr_debug("No supply entry present for %s\n",
					supply_name);
@@ -244,7 +239,7 @@ int dsi_pwr_of_get_vreg_data(struct device_node *of_node,
		}
	}

	regs->count = of_get_available_child_count(supply_root_node);
	regs->count = utils->get_available_child_count(supply_root_node);
	if (regs->count == 0) {
		pr_err("No vregs defined for %s\n", supply_name);
		return -EINVAL;
@@ -256,7 +251,7 @@ int dsi_pwr_of_get_vreg_data(struct device_node *of_node,
		return -ENOMEM;
	}

	rc = dsi_pwr_parse_supply_node(supply_root_node, regs);
	rc = dsi_pwr_parse_supply_node(utils, supply_root_node, regs);
	if (rc) {
		pr_err("failed to parse supply node for %s, rc = %d\n",
			supply_name, rc);
@@ -285,6 +280,7 @@ int dsi_pwr_get_dt_vreg_data(struct device *dev,
	struct device_node *of_node = NULL;
	struct device_node *supply_node = NULL;
	struct device_node *supply_root_node = NULL;
	struct dsi_parser_utils utils = *dsi_parser_get_of_utils();

	if (!dev || !regs) {
		pr_err("Bad params\n");
@@ -318,7 +314,10 @@ int dsi_pwr_get_dt_vreg_data(struct device *dev,
		return -ENOMEM;
	}

	rc = dsi_pwr_parse_supply_node(supply_root_node, regs);
	utils.data = of_node;
	utils.node = of_node;

	rc = dsi_pwr_parse_supply_node(&utils, supply_root_node, regs);
	if (rc) {
		pr_err("failed to parse supply node for %s, rc = %d\n",
		       supply_name, rc);
Loading