/** * mdss_dsi_find_panel_of_node(): find device node of dsi panel * @pdev: platform_device of the dsi ctrl node * @panel_cfg: string containing intf specific config data * * Function finds the panel device node using the interface * specific configuration data. This configuration data is * could be derived from the result of bootloader's GCDB * panel detection mechanism. If such config data doesn't * exist then this panel returns the default panel configured * in the device tree. * * returns pointer to panel node on success, NULL on error. */ static struct device_node *mdss_dsi_find_panel_of_node( struct platform_device *pdev, char *panel_cfg, struct mdss_dsi_ctrl_pdata *ctrl_pdata) { int len, i; int ctrl_id = pdev->id - 1; char panel_name[MDSS_MAX_PANEL_LEN]; char ctrl_id_stream[3] = "0:"; char *stream = NULL, *pan = NULL; struct device_node *dsi_pan_node = NULL, *mdss_node = NULL; len = strlen(panel_cfg); if (!len) { dsi_pan_node = mdss_dsi_panel_search_dt_nodes(pdev, ctrl_pdata); if (dsi_pan_node) return dsi_pan_node; /* no panel cfg chg, parse dt */ pr_debug("%s:%d: no cmd line cfg present\n", __func__, __LINE__); goto end; } else { if (ctrl_id == 1) strlcpy(ctrl_id_stream, "1:", 3); stream = strnstr(panel_cfg, ctrl_id_stream, len); if (!stream) { pr_err("controller config is not present\n"); goto end; } stream += 2; pan = strnchr(stream, strlen(stream), ':'); if (!pan) { strlcpy(panel_name, stream, MDSS_MAX_PANEL_LEN); } else { for (i = 0; (stream + i) < pan; i++) panel_name[i] = *(stream + i); panel_name[i] = 0; } pr_debug("%s:%d:%s:%s\n", __func__, __LINE__, panel_cfg, panel_name); mdss_node = of_parse_phandle(pdev->dev.of_node, "qcom,mdss-mdp", 0); if (!mdss_node) { pr_err("%s: %d: mdss_node null\n", __func__, __LINE__); return NULL; } dsi_pan_node = of_find_node_by_name(mdss_node, panel_name); if (!dsi_pan_node) { pr_err("%s: invalid pan node, selecting prim panel\n", __func__); goto end; } return dsi_pan_node; } end: dsi_pan_node = mdss_dsi_pref_prim_panel(pdev); return dsi_pan_node; }
/** * mdss_dsi_find_panel_of_node(): find device node of dsi panel * @pdev: platform_device of the dsi ctrl node * @panel_cfg: string containing intf specific config data * * Function finds the panel device node using the interface * specific configuration data. This configuration data is * could be derived from the result of bootloader's GCDB * panel detection mechanism. If such config data doesn't * exist then this panel returns the default panel configured * in the device tree. * * returns pointer to panel node on success, NULL on error. */ static struct device_node *mdss_dsi_find_panel_of_node( struct platform_device *pdev, char *panel_cfg, struct mdss_dsi_ctrl_pdata *ctrl_pdata) { int l; int ctrl_id = -1; char *panel_name; struct device_node *dsi_pan_node = NULL, *mdss_node = NULL; l = strlen(panel_cfg); if (!l) { dsi_pan_node = mdss_dsi_panel_search_dt_nodes(pdev, ctrl_pdata); if (dsi_pan_node) return dsi_pan_node; /* no panel cfg chg, parse dt */ pr_debug("%s:%d: no cmd line cfg present\n", __func__, __LINE__); dsi_pan_node = of_parse_phandle( pdev->dev.of_node, "qcom,dsi-pref-prim-pan", 0); if (!dsi_pan_node) { pr_err("%s:can't find panel phandle\n", __func__); return NULL; } } else { if (panel_cfg[0] == '0') { pr_debug("%s:%d: DSI ctrl 1\n", __func__, __LINE__); ctrl_id = 0; } else if (panel_cfg[0] == '1') { pr_debug("%s:%d: DSI ctrl 2\n", __func__, __LINE__); ctrl_id = 1; } if ((pdev->id - 1) != ctrl_id) { pr_err("%s:%d:pdev_ID=[%d]\n", __func__, __LINE__, pdev->id); return NULL; } /* * skip first two chars '<dsi_ctrl_id>' and * ':' to get to the panel name */ panel_name = panel_cfg + 2; pr_debug("%s:%d:%s:%s\n", __func__, __LINE__, panel_cfg, panel_name); mdss_node = of_parse_phandle(pdev->dev.of_node, "qcom,mdss-mdp", 0); if (!mdss_node) { pr_err("%s: %d: mdss_node null\n", __func__, __LINE__); return NULL; } dsi_pan_node = of_find_node_by_name(mdss_node, panel_name); if (!dsi_pan_node) { pr_err("%s: invalid pan node\n", __func__); return NULL; } } return dsi_pan_node; }