RK3399- hdmi-in (tc35874)添加插拔状态读取

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 <media/v4l2-event.h>
 #include <media/v4l2-fwnode.h>
 #include <media/tc35874x.h>
-
+#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)
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

那肯定是很多年以后!

你的鼓励就我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值