• 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 
     #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)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
  • 相关阅读:
    提分必练!中创教育PMP全真模拟题分享来喽
    RabbitMQ基础概念-02
    sql同表分组取第一条
    C/C++内存管理学习【new】
    有什么低价好用的电容笔推荐?大一新生必备物品
    python使用Postgre数据库使用geometry和批量插入数据以及python库psycopg2操作postgre数据库踩坑
    机器学习参数|数学建模|自相关性
    如何像优秀测试人员那样思考?
    年薪20W和100W的项目经理,差别在哪?
    2022-08-01 网工进阶(二十四) STP进阶知识
  • 原文地址:https://blog.csdn.net/qq_38312843/article/details/126872988