rk399_android7.1的mipi驱动代码追踪(部分)



文件:./drivers/gpu/drm/panel/panel-simple.c
我这里从probe函数开始追踪源码
	->panel_simple_dsi_probe
		->id = of_match_node(dsi_of_match, dev->of_node);
		->panel_simple_probe
			->of_property_read_u32 //解析一些dts的配置参数
			->err = panel_simple_get_cmds(panel); //解析dts配置的mipi初始化参数
				---------------- get cmd ----------------
				->data = of_get_property(panel->dev->of_node, "panel-init-sequence", &len); //解析判断dts是否有初始化进入mipi模块参数
				->err = panel_simple_parse_cmds(panel->dev, data, len, panel->on_cmds); //解析初始化mipi参数
				->data = of_get_property(panel->dev->of_node, "panel-exit-sequence", &len); //解析判断dts是否有初始化退出mipi模块参数
				->err = panel_simple_parse_cmds(panel->dev, data, len, panel->off_cmds); //解析初始化mipi参数
				---------------- get cmd ----------------
			
			->drm_panel_init(&panel->base); //屏的初始化
				->INIT_LIST_HEAD(&panel->list);
		
			->panel->base.funcs = &panel_simple_funcs; //关联mipi屏的操作接口函数
				->panel_simple_funcs = {
					.loader_protect = panel_simple_loader_protect, //屏使能准备
						-> err = panel_simple_regulator_enable(panel); //mipi控制器使能
							->err = regulator_enable(p->supply);
						->p->prepared = true; //把一些属性设置为true,意为打开该功能
						->p->enabled = true;
					.disable = panel_simple_disable, //屏关闭
						->backlight_disable(p->backlight); //关背光
						->panel_simple_sleep(p->desc->delay.disable); //延时
						->p->enabled = false; //把enabled属性设置为false
					.unprepare = panel_simple_unprepare, //为屏关闭做准备工作
						->err = panel_simple_dsi_send_cmds(p, p->off_cmds); //发送mipi 指令
							->err = mipi_dsi_dcs_write_buffer(dsi, cmd->payload, cmd->dchdr.dlen);
							->panel_simple_sleep(cmd->dchdr.wait); //延时
					.prepare = panel_simple_prepare, //为屏打开做准备工作
						->err = panel_simple_regulator_enable(panel); //mipi控制器使能
						->gpiod_direction_output(p->enable_gpio, 1); //一些GPIO的操作,可以控制屏的上电使能和复位等操作,通过panel_simple_sleep设置延时达到控制时序的目的
						->panel_simple_sleep(p->desc->delay.prepare);
						->gpiod_direction_output(p->reset_gpio, 1);
						->panel_simple_sleep(p->desc->delay.reset);
						->...
						
						->if (p->on_cmds) { //发送mipi指令
							if (p->dsi)
								err = panel_simple_dsi_send_cmds(p, p->on_cmds);
							else if (p->cmd_type == CMD_TYPE_SPI)
								err = panel_simple_spi_send_cmds(p, p->on_cmds);
							}
						->p->prepared = true;
						
					.enable = panel_simple_enable, //屏使能
						->backlight_enable(p->backlight); //打开背光
						->p->enabled = true;
					.get_modes = panel_simple_get_modes, //获取mipi显示分辨率
						->num += panel_simple_of_get_native_mode(p);
							->timings_np = of_get_child_by_name(panel->dev->of_node, "display-timings");
								->ret = of_get_drm_display_mode(panel->dev->of_node, mode, OF_USE_NATIVE_MODE);
									->ret = of_get_videomode(np, &vm, index); //在文件./drivers/gpu/drm/drm_modes.c中
									->drm_display_mode_from_videomode(&vm, dmode);
						->num += panel_simple_get_fixed_modes(p);
						->if (p->ddc) { //如果DDC总线可用,则探测EDID
							struct edid *edid = drm_get_edid(panel->connector, p->ddc);
								if (edid) { //判断是否有读取到edid
								num += drm_add_edid_modes(panel->connector, edid);
								}
							}
						
					.get_timings = panel_simple_get_timings, //获取屏的时序参数timings
						->if (timings)
								for (i = 0; i < num_timings; i++)
									timings[i] = p->desc->timings[i];
						};
				
			->err = drm_panel_add(&panel->base); //添加mipi屏到drm panel链表中,函数原型在./drivers/gpu/drm/drm_panel.c中
				->list_add_tail(&panel->list, &panel_list); //添加对象到链表调用list_add_tail

你可能感兴趣的:(RK系列驱动开发)