HDMI驱动热插拔检测方法

时间:2023-03-09 06:55:19
HDMI驱动热插拔检测方法

1. 使用poll机制

1.1 如何使用?

a. open("/dev/HPD");

b. poll状态发生变化

c. read确定接上还是接下

1.2 情景分析:

  1. APP使用open("/dev/HPD");
  2. APP : poll -> 驱动:poll -> 休眠 -> 中断
  3. APP : read

2. state主动上报数据

2.1 switch设备简介:

2.1.1. 构造switch_dev:

.name = "hdmi";
.state = 1,0;

2.1.2 switch_dev_register

a. 创建class_create("switch");

/sys/class/switch

b. 在类下创建设备device_create("hdmi");

/sys/class/switch/hdmi

c. device_create_file("state");

/sys/class/switch/state

2.2 使用switch系统

2.2.1 第一种方法:

  1. 中断程序设置switch_dev的state
  2. APP读/sys/class/switch/state

这种方法相当耗资源

2.2.2 第二种方法:

  1. APP设置网络(读数据)

  2. 驱动:中断-> schdule_work -> 发送网络数据

    a. 构造envp[]

    b. kobject_uevent_env发送给user app

    b.1 使用网络发送envp

    b.2 /sbin/hotplug

  3. APP被唤醒,读、处理