hdmi: uevent is bind to vitual display device.
authorZheng Yang <zhengyang@rock-chips.com>
Sat, 9 Aug 2014 08:26:11 +0000 (16:26 +0800)
committerZheng Yang <zhengyang@rock-chips.com>
Sat, 9 Aug 2014 08:26:11 +0000 (16:26 +0800)
drivers/video/rockchip/hdmi/rk_hdmi.h
drivers/video/rockchip/hdmi/rk_hdmi_sysfs.c
drivers/video/rockchip/hdmi/rk_hdmi_task.c

index 4f5f9fe1f2dc85d41964335a0cf40abec08de1e7..8a42d9da3719f09751d762333dc184e3e1fc0049 100755 (executable)
@@ -88,9 +88,7 @@ enum {
        VIDEO_INPUT_COLOR_YCBCR422,
        VIDEO_INPUT_COLOR_YCBCR420
 };
-/********************************************************************
-**                          ½á¹¹¶¨Òå                                *
-********************************************************************/
+
 /* HDMI video mode code according CEA-861-E */
 enum hdmi_video_mode {
        HDMI_640x480p_60Hz = 1,
@@ -289,7 +287,7 @@ struct hdmi_edid {
        struct hdmi_audio *audio;       /* Device supported audio info */
        int audio_num;                  /* Device supported audio type number */
        int base_audio_support;         /* Device supported base audio */
-       unsigned int  cecaddress;                       //CEC physical address
+       unsigned int  cecaddress;       /* CEC physical address */
 };
 
 /* RK HDMI Video Configure Parameters */
@@ -322,7 +320,7 @@ struct hdmi {
        int irq;
        struct rk_lcdc_driver *lcdc;
        struct rk_hdmi_drvdata *data;
-
+       struct rk_display_device *ddev;
 #ifdef CONFIG_SWITCH
        struct switch_dev switch_hdmi;
 #endif
@@ -361,28 +359,28 @@ struct hdmi {
 
        struct list_head pwrlist_head;
 
-       int (*insert) (struct hdmi *hdmi);
-       int (*remove) (struct hdmi *hdmi);
-       void (*control_output) (struct hdmi *hdmi, int enable);
-       int (*config_video) (struct hdmi *hdmi,
+       int (*insert)(struct hdmi *hdmi);
+       int (*remove)(struct hdmi *hdmi);
+       void (*control_output)(struct hdmi *hdmi, int enable);
+       int (*config_video)(struct hdmi *hdmi,
                             struct hdmi_video_para *vpara);
-       int (*config_audio) (struct hdmi *hdmi, struct hdmi_audio *audio);
-       int (*detect_hotplug) (struct hdmi *hdmi);
+       int (*config_audio)(struct hdmi *hdmi, struct hdmi_audio *audio);
+       int (*detect_hotplug)(struct hdmi *hdmi);
        /* call back for edid */
-       int (*read_edid) (struct hdmi *hdmi, int block, unsigned char *buff);
-       int (*set_vif) (struct hdmi *hdmi, struct rk_screen *screen,
+       int (*read_edid)(struct hdmi *hdmi, int block, unsigned char *buff);
+       int (*set_vif)(struct hdmi *hdmi, struct rk_screen *screen,
                        bool connect);
 
        /* call back for hdcp operation */
-       void (*hdcp_cb) (void);
-       void (*hdcp_irq_cb) (int);
-       int (*hdcp_power_on_cb) (void);
-       void (*hdcp_power_off_cb) (void);
+       void (*hdcp_cb)(void);
+       void (*hdcp_irq_cb)(int);
+       int (*hdcp_power_on_cb)(void);
+       void (*hdcp_power_off_cb)(void);
 
        /*call back for cec operation*/
-       void (*cec_irq) (void);
-       void (*cec_set_device_pa) (int);
-       int (*cec_enumerate) (void);
+       void (*cec_irq)(void);
+       void (*cec_set_device_pa)(int);
+       int (*cec_enumerate)(void);
 };
 
 #define hdmi_err(dev, format, arg...)          \
@@ -395,28 +393,28 @@ struct hdmi {
 #define hdmi_dbg(dev, format, arg...)
 #endif
 
-extern int hdmi_drv_register(struct hdmi *hdmi_drv);
-extern int hdmi_get_hotplug(void);
-extern int hdmi_set_info(struct rk_screen *screen, unsigned int vic);
-extern void hdmi_init_lcdc(struct rk_screen *screen,
+int hdmi_drv_register(struct hdmi *hdmi_drv);
+int hdmi_get_hotplug(void);
+int hdmi_set_info(struct rk_screen *screen, unsigned int vic);
+void hdmi_init_lcdc(struct rk_screen *screen,
                           struct rk29lcd_info *lcd_info);
-extern int hdmi_sys_init(struct hdmi *hdmi_drv);
-extern int hdmi_sys_parse_edid(struct hdmi *hdmi_drv);
-extern const char *hdmi_get_video_mode_name(unsigned char vic);
-extern int hdmi_videomode_to_vic(struct fb_videomode *vmode);
-extern const struct fb_videomode *hdmi_vic_to_videomode(int vic);
-extern int hdmi_add_videomode(const struct fb_videomode *mode,
+int hdmi_sys_init(struct hdmi *hdmi_drv);
+int hdmi_sys_parse_edid(struct hdmi *hdmi_drv);
+const char *hdmi_get_video_mode_name(unsigned char vic);
+int hdmi_videomode_to_vic(struct fb_videomode *vmode);
+const struct fb_videomode *hdmi_vic_to_videomode(int vic);
+int hdmi_add_videomode(const struct fb_videomode *mode,
                              struct list_head *head);
-extern struct hdmi_video_timing *hdmi_find_mode(int vic);
-extern int hdmi_find_best_mode(struct hdmi *hdmi_drv, int vic);
-extern int hdmi_ouputmode_select(struct hdmi *hdmi_drv, int edid_ok);
-extern int hdmi_switch_fb(struct hdmi *hdmi_drv, int vic);
-extern int hdmi_init_video_para(struct hdmi *hdmi_drv,
+struct hdmi_video_timing *hdmi_find_mode(int vic);
+int hdmi_find_best_mode(struct hdmi *hdmi_drv, int vic);
+int hdmi_ouputmode_select(struct hdmi *hdmi_drv, int edid_ok);
+int hdmi_switch_fb(struct hdmi *hdmi_drv, int vic);
+int hdmi_init_video_para(struct hdmi *hdmi_drv,
                                struct hdmi_video_para *video);
-extern void hdmi_work(struct work_struct *work);
-extern void hdmi_register_display_sysfs(struct hdmi *hdmi_drv,
+void hdmi_work(struct work_struct *work);
+void hdmi_register_display_sysfs(struct hdmi *hdmi_drv,
                                        struct device *parent);
-extern void hdmi_unregister_display_sysfs(struct hdmi *hdmi_drv);
+void hdmi_unregister_display_sysfs(struct hdmi *hdmi_drv);
 
 int rk_hdmi_parse_dt(struct hdmi *hdmi_drv);
 int rk_hdmi_pwr_enable(struct hdmi *dev_drv);
index 321f7fa0fb3cfe30069eb47fe1fafa69f02efa68..09855e5e4ba20502725c2490e2b6502cdde213ea 100755 (executable)
@@ -50,6 +50,7 @@ static int hdmi_set_enable(struct rk_display_device *device, int enable)
 static int hdmi_get_status(struct rk_display_device *device)
 {
        struct hdmi *hdmi = device->priv_data;
+
        if (hdmi->hotplug == HDMI_HPD_ACTIVED)
                return 1;
        else
@@ -60,6 +61,7 @@ static int hdmi_get_modelist(struct rk_display_device *device,
                             struct list_head **modelist)
 {
        struct hdmi *hdmi = device->priv_data;
+
        if (!hdmi->hotplug)
                return -1;
        *modelist = &hdmi->edid.modelist;
@@ -171,7 +173,6 @@ static struct rk_display_driver display_hdmi = {
        .probe = hdmi_display_probe,
 };
 
-static struct rk_display_device *display_device_hdmi;
 #ifdef CONFIG_DRM_ROCKCHIP
 extern void rk_drm_display_register(struct rk_display_ops *extend_ops,
                                    void *displaydata, int type);
@@ -179,7 +180,7 @@ extern void rk_drm_display_register(struct rk_display_ops *extend_ops,
 
 void hdmi_register_display_sysfs(struct hdmi *hdmi, struct device *parent)
 {
-       display_device_hdmi =
+       hdmi->ddev =
            rk_display_device_register(&display_hdmi, parent, hdmi);
 #ifdef CONFIG_DRM_ROCKCHIP
        rk_drm_display_register(&hdmi_display_ops, hdmi, SCREEN_HDMI);
@@ -188,7 +189,7 @@ void hdmi_register_display_sysfs(struct hdmi *hdmi, struct device *parent)
 
 void hdmi_unregister_display_sysfs(struct hdmi *hdmi)
 {
-       if (display_device_hdmi)
-               rk_display_device_unregister(display_device_hdmi);
+       if (hdmi->ddev)
+               rk_display_device_unregister(hdmi->ddev);
 }
 #endif
index ba88a132145a57d257f67085e5f54d67b54bd234..9674407bea98f48669f5a5b5564ddcea86a62231 100755 (executable)
@@ -68,8 +68,8 @@ void hdmi_sys_remove(struct hdmi *hdmi)
 {
        int audio_need;
 
-       audio_need = hdmi->edid.base_audio_support == 1
-           && hdmi->edid.sink_hdmi == 1;
+       audio_need = hdmi->edid.base_audio_support == 1 &&
+                       hdmi->edid.sink_hdmi == 1;
 
        fb_destroy_modelist(&hdmi->edid.modelist);
        kfree(hdmi->edid.audio);
@@ -83,7 +83,7 @@ void hdmi_sys_remove(struct hdmi *hdmi)
        if (hdmi->set_vif)
                hdmi->set_vif(hdmi, hdmi->lcdc->screen1, 0);
        rk_fb_switch_screen(hdmi->lcdc->screen1, 0, hdmi->lcdc->id);
-       kobject_uevent_env(&hdmi->dev->kobj, KOBJ_REMOVE, envp);
+       kobject_uevent_env(&hdmi->ddev->dev->kobj, KOBJ_REMOVE, envp);
 
 #ifdef CONFIG_SWITCH
        if (audio_need)
@@ -144,9 +144,9 @@ static int hdmi_process_command(struct hdmi *hdmi)
                        break;
                case HDMI_CONFIG_VIDEO:
                default:
-                       if (state > SYSTEM_CONFIG)
+                       if (state > SYSTEM_CONFIG) {
                                state = SYSTEM_CONFIG;
-                       else {
+                       else {
                                if (hdmi->wait == 1) {
                                        complete(&hdmi->complete);
                                        hdmi->wait = 0;
@@ -154,8 +154,9 @@ static int hdmi_process_command(struct hdmi *hdmi)
                        }
                        break;
                }
-       } else if (state == HDMI_SLEEP)
+       } else if (state == HDMI_SLEEP) {
                state = WAIT_HOTPLUG;
+       }
        return state;
 }
 
@@ -190,9 +191,9 @@ void hdmi_work(struct work_struct *work)
                } else if (hdmi->hotplug == HDMI_HPD_ACTIVED) {
                        hdmi->hotplug = hotplug;
                        hdmi_sys_remove(hdmi);
-                       if (hotplug == HDMI_HPD_REMOVED)
+                       if (hotplug == HDMI_HPD_REMOVED) {
                                hdmi_sys_sleep(hdmi);
-                       else {
+                       else {
                                hdmi->state = WAIT_HOTPLUG;
                                hdmi->remove(hdmi);
                        }
@@ -207,9 +208,9 @@ void hdmi_work(struct work_struct *work)
                        hdmi->remove(hdmi);
                }
                hdmi->hotplug = hotplug;
-       } else if (hotplug == HDMI_HPD_REMOVED)
+       } else if (hotplug == HDMI_HPD_REMOVED) {
                hdmi_sys_sleep(hdmi);
-
+       }
        do {
                hdmi_sys_show_state(hdmi);
                state_last = hdmi->state;
@@ -217,21 +218,21 @@ void hdmi_work(struct work_struct *work)
                case READ_PARSE_EDID:
                        rc = hdmi_sys_parse_edid(hdmi);
                        if (rc == HDMI_ERROR_SUCESS) {
-                               if(hdmi->cec_set_device_pa)
+                               if (hdmi->cec_set_device_pa)
                                        hdmi->cec_set_device_pa(hdmi->edid.cecaddress);
-                               if(hdmi->cec_enumerate)
+                               if (hdmi->cec_enumerate)
                                        hdmi->cec_enumerate();
                                hdmi->state = SYSTEM_CONFIG;
-                               kobject_uevent_env(&hdmi->dev->kobj, KOBJ_ADD,
-                                                  envp);
+                               kobject_uevent_env(&hdmi->ddev->dev->kobj,
+                                                  KOBJ_ADD, envp);
                                hdmi_dbg(hdmi->dev,
                                         "[%s] base_audio_support =%d,sink_hdmi = %d\n",
                                         __func__,
                                         hdmi->edid.base_audio_support,
                                         hdmi->edid.sink_hdmi);
 #ifdef CONFIG_SWITCH
-                               if (hdmi->edid.base_audio_support == 1
-                                   && hdmi->edid.sink_hdmi == 1)
+                               if (hdmi->edid.base_audio_support == 1 &&
+                                   hdmi->edid.sink_hdmi == 1)
                                        switch_set_state(&(hdmi->switch_hdmi),
                                                         1);
 #endif
@@ -272,9 +273,8 @@ void hdmi_work(struct work_struct *work)
                        if (hdmi->display != HDMI_ENABLE) {
                                hdmi->control_output(hdmi, HDMI_ENABLE);
                                hdmi->display = HDMI_ENABLE;
-                               if (hdmi->hdcp_cb) {
+                               if (hdmi->hdcp_cb)
                                        hdmi->hdcp_cb();
-                               }
                        }
 
                        if (hdmi->wait == 1) {
@@ -292,8 +292,9 @@ void hdmi_work(struct work_struct *work)
                if (hdmi->state != state_last)
                        trytimes = 0;
 
-       } while ((hdmi->state != state_last || (rc != HDMI_ERROR_SUCESS))
-                && trytimes < HDMI_MAX_TRY_TIMES);
+       } while ((hdmi->state != state_last ||
+                (rc != HDMI_ERROR_SUCESS)) &&
+                trytimes < HDMI_MAX_TRY_TIMES);
 
        hdmi_dbg(hdmi->dev, "[%s] done\n", __func__);
        mutex_unlock(&work_mutex);