tc35874添加插拔状态读取
diff --git a/drivers/media/i2c/tc35874x.c b/drivers/media/i2c/tc35874x.c
index 1dbbe93..87cec07 100755
--- a/drivers/media/i2c/tc35874x.c
+++ b/drivers/media/i2c/tc35874x.c
@@ -48,7 +48,7 @@
#include
#include
#include
-
+#include <linux/switch.h>
#include "tc35874x_regs.h"
static int debug;
@@ -230,7 +230,21 @@ static void tc35874x_enable_interrupts(struct v4l2_subdev *sd,
static int tc35874x_s_ctrl_detect_tx_5v(struct v4l2_subdev *sd);
static int tc35874x_s_dv_timings(struct v4l2_subdev *sd,
struct v4l2_dv_timings *timings);
-
+struct switch_dev sdev;
+static int video_in_switch(void)
+{
+ int ret;
+ sdev.name = "hdmiin";//注册之后就会在/sys/class/switch下生成相应名字命名的文件
+ sdev.state = 0;
+ sdev.index = 0;
+ //注册switch_dev类设备
+ ret = switch_dev_register(&sdev);
+ if (ret < 0){
+ switch_dev_unregister(&sdev);
+ return ret;
+ }
+ sdev.name = "hdmiin";//这里改变的是switch文件下name的值,cat name可以看到
+ return 0;
+}
static inline struct tc35874x_state *to_state(struct v4l2_subdev *sd)
{
return container_of(sd, struct tc35874x_state, sd);
@@ -511,6 +525,7 @@ static int tc35874x_get_detected_timings(struct v4l2_subdev *sd,
static void tc35874x_delayed_work_enable_hotplug(struct work_struct *work)
{
+ u8 HPD_CTL_STATE=0;
struct delayed_work *dwork = to_delayed_work(work);
struct tc35874x_state *state = container_of(dwork,
struct tc35874x_state, delayed_work_enable_hotplug);
@@ -519,6 +534,10 @@ static void tc35874x_delayed_work_enable_hotplug(struct work_struct *work)
v4l2_dbg(2, debug, sd, "%s:\n", __func__);
i2c_wr8_and_or(sd, HPD_CTL, ~MASK_HPD_OUT0, MASK_HPD_OUT0);
+ HPD_CTL_STATE = i2c_rd8(sd,HPD_CTL);
+ printk("%d,%s\n",HPD_CTL_STATE,__func__);
+ //向用户态传递消息,应用层读取这个就能够实现状态获取。
+ switch_set_state(&sdev, HPD_CTL_STATE);
}
static void tc35874x_set_hdmi_hdcp(struct v4l2_subdev *sd, bool enable)
@@ -545,6 +564,7 @@ static void tc35874x_set_hdmi_hdcp(struct v4l2_subdev *sd, bool enable)
static void tc35874x_disable_edid(struct v4l2_subdev *sd)
{
+ u8 HPD_CTL_STATE=0;
struct tc35874x_state *state = to_state(sd);
v4l2_dbg(2, debug, sd, "%s:\n", __func__);
@@ -554,6 +574,9 @@ static void tc35874x_disable_edid(struct v4l2_subdev *sd)
/* DDC access to EDID is also disabled when hotplug is disabled. See
* register DDC_CTL */
i2c_wr8_and_or(sd, HPD_CTL, ~MASK_HPD_OUT0, 0x0);
+ HPD_CTL_STATE = i2c_rd8(sd,HPD_CTL);
+ printk("%d,%s\n",HPD_CTL_STATE,__func__);
+ switch_set_state(&sdev, HPD_CTL_STATE);
}
static void tc35874x_enable_edid(struct v4l2_subdev *sd)
@@ -2410,9 +2433,8 @@ static int tc35874x_probe(struct i2c_client *client,
v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name,
client->addr << 1, client->adapter->name);
-
+ video_in_switch();
return 0;
-
err_work_queues:
if (!state->i2c_client->irq)