hdmi: use dps->lock replace of hdmi->lock.
authorZheng Yang <zhengyang@rock-chips.com>
Mon, 20 Jul 2015 06:52:13 +0000 (14:52 +0800)
committerZheng Yang <zhengyang@rock-chips.com>
Mon, 20 Jul 2015 06:52:13 +0000 (14:52 +0800)
Signed-off-by: Zheng Yang <zhengyang@rock-chips.com>
drivers/video/rockchip/display-sys.c
drivers/video/rockchip/hdmi/rockchip-hdmi-core.c
drivers/video/rockchip/hdmi/rockchip-hdmi-sysfs.c

index 534f00d01248f48c32263506389d39d10059bcc2..408e9864734a5ee157da5b6f4aa1e4b169daf24e 100755 (executable)
@@ -162,16 +162,20 @@ static ssize_t display_store_mode(struct device *dev,
        struct fb_videomode *mode;
        size_t i;
 
+       mutex_lock(&dsp->lock);
        if (!memcmp(buf, "auto", 4)) {
                if (dsp->ops && dsp->ops->setmode)
                        dsp->ops->setmode(dsp, NULL);
+               mutex_unlock(&dsp->lock);
                return count;
        }
 
        if (dsp->ops && dsp->ops->getmodelist) {
                if (dsp->ops && dsp->ops->getmodelist) {
-                       if (dsp->ops->getmodelist(dsp, &modelist))
+                       if (dsp->ops->getmodelist(dsp, &modelist)) {
+                               mutex_unlock(&dsp->lock);
                                return -EINVAL;
+                       }
                }
                list_for_each(pos, modelist) {
                        display_modelist = list_entry(pos,
@@ -182,10 +186,12 @@ static ssize_t display_store_mode(struct device *dev,
                        if (strncmp(mstr, buf, max(count, i)) == 0) {
                                if (dsp->ops && dsp->ops->setmode)
                                        dsp->ops->setmode(dsp, mode);
+                               mutex_unlock(&dsp->lock);
                                return count;
                        }
                }
        }
+       mutex_unlock(&dsp->lock);
        return -EINVAL;
 }
 
@@ -251,17 +257,24 @@ static ssize_t display_show_3dmode(struct device *dev,
        char mode_str[128];
        int mode_strlen, format_3d;
 
+       mutex_lock(&dsp->lock);
        if (dsp->ops && dsp->ops->getmodelist) {
-               if (dsp->ops->getmodelist(dsp, &modelist))
+               if (dsp->ops->getmodelist(dsp, &modelist)) {
+                       mutex_unlock(&dsp->lock);
                        return -EINVAL;
+               }
        } else {
+               mutex_unlock(&dsp->lock);
                return 0;
        }
 
        if (dsp->ops && dsp->ops->getmode) {
-               if (dsp->ops->getmode(dsp, &mode))
+               if (dsp->ops->getmode(dsp, &mode)) {
+                       mutex_unlock(&dsp->lock);
                        return -EINVAL;
+               }
        } else {
+               mutex_unlock(&dsp->lock);
                return 0;
        }
 
@@ -295,6 +308,7 @@ static ssize_t display_show_3dmode(struct device *dev,
                i += snprintf(buf+i, PAGE_SIZE, "%s,%d\n",
                              mode_str, format_3d);
        }
+       mutex_unlock(&dsp->lock);
        return i;
 }
 
@@ -305,11 +319,14 @@ static ssize_t display_store_3dmode(struct device *dev,
        struct rk_display_device *dsp = dev_get_drvdata(dev);
        int mode;
 
+       mutex_lock(&dsp->lock);
        if (dsp->ops && dsp->ops->set3dmode) {
                if (!kstrtoint(buf, 0, &mode))
                        dsp->ops->set3dmode(dsp, mode);
+               mutex_unlock(&dsp->lock);
                return count;
        }
+       mutex_unlock(&dsp->lock);
        return -EINVAL;
 }
 
@@ -317,11 +334,13 @@ static ssize_t display_show_color(struct device *dev,
                                  struct device_attribute *attr, char *buf)
 {
        struct rk_display_device *dsp = dev_get_drvdata(dev);
+       int ret = 0;
 
+       mutex_lock(&dsp->lock);
        if (dsp->ops && dsp->ops->getcolor)
-               return dsp->ops->getcolor(dsp, buf);
-       else
-               return 0;
+               ret = dsp->ops->getcolor(dsp, buf);
+       mutex_unlock(&dsp->lock);
+       return ret;
 }
 
 static ssize_t display_store_color(struct device *dev,
@@ -330,10 +349,14 @@ static ssize_t display_store_color(struct device *dev,
 {
        struct rk_display_device *dsp = dev_get_drvdata(dev);
 
+       mutex_lock(&dsp->lock);
        if (dsp->ops && dsp->ops->setcolor) {
-               if (!dsp->ops->setcolor(dsp, buf, count))
+               if (!dsp->ops->setcolor(dsp, buf, count)) {
+                       mutex_unlock(&dsp->lock);
                        return count;
+               }
        }
+       mutex_unlock(&dsp->lock);
        return -EINVAL;
 }
 
@@ -345,11 +368,15 @@ static ssize_t display_show_sinkaudioinfo(struct device *dev,
        char audioinfo[200];
        int ret = 0;
 
+       mutex_lock(&dsp->lock);
        if (dsp->ops && dsp->ops->getedidaudioinfo) {
                ret = dsp->ops->getedidaudioinfo(dsp, audioinfo, 200);
-               if (!ret)
+               if (!ret) {
+                       mutex_unlock(&dsp->lock);
                        return snprintf(buf, PAGE_SIZE, "%s\n", audioinfo);
+               }
        }
+       mutex_unlock(&dsp->lock);
        return -EINVAL;
 }
 
@@ -360,13 +387,16 @@ static ssize_t display_show_monspecs(struct device *dev,
        struct fb_monspecs monspecs;
        int ret = 0;
 
+       mutex_lock(&dsp->lock);
        if (dsp->ops && dsp->ops->getmonspecs) {
                ret = dsp->ops->getmonspecs(dsp, &monspecs);
                if (!ret) {
+                       mutex_unlock(&dsp->lock);
                        memcpy(buf, &monspecs, sizeof(struct fb_monspecs));
                        return sizeof(struct fb_monspecs);
                }
        }
+       mutex_unlock(&dsp->lock);
        return -EINVAL;
 }
 
@@ -374,26 +404,30 @@ static ssize_t display_show_debug(struct device *dev,
                                  struct device_attribute *attr, char *buf)
 {
        struct rk_display_device *dsp = dev_get_drvdata(dev);
+       int ret = -EINVAL;
 
+       mutex_lock(&dsp->lock);
        if (dsp->ops && dsp->ops->getdebug)
-               return dsp->ops->getdebug(dsp, buf);
-       else
-               return -EINVAL;
+               ret = dsp->ops->getdebug(dsp, buf);
+       mutex_unlock(&dsp->lock);
+       return ret;
 }
 
 static ssize_t display_store_debug(struct device *dev,
                                   struct device_attribute *attr,
                                   const char *buf, size_t count)
 {
-       int cmd;
+       int cmd, ret = -EINVAL;
        struct rk_display_device *dsp = dev_get_drvdata(dev);
 
+       mutex_lock(&dsp->lock);
        if (dsp->ops && dsp->ops->setdebug) {
                if (kstrtoint(buf, 0, &cmd) == 0)
                        dsp->ops->setdebug(dsp, cmd);
-               return count;
+               ret = count;
        }
-       return -EINVAL;
+       mutex_unlock(&dsp->lock);
+       return ret;
 }
 
 static struct device_attribute display_attrs[] = {
index a28c04de5441af0e6a6d1e9452422b2dc262dbb0..a97c9209a7cd09e015200a21d49463309063575f 100644 (file)
@@ -79,7 +79,6 @@ static void hdmi_wq_set_video(struct hdmi *hdmi)
 
        DBG("%s\n", __func__);
 
-       video.vic = hdmi->vic & HDMI_VIC_MASK;
        video.sink_hdmi = hdmi->edid.sink_hdmi;
        video.format_3d = hdmi->mode_3d;
        video.colorimetry = hdmi->colorimetry;
@@ -124,6 +123,7 @@ static void hdmi_wq_set_video(struct hdmi *hdmi)
        }
        hdmi->colormode_input = video.color_input;
        hdmi_set_lcdc(hdmi);
+       video.vic = hdmi->vic & HDMI_VIC_MASK;
        if (hdmi->ops->setvideo)
                hdmi->ops->setvideo(hdmi, &video);
 }
@@ -260,12 +260,10 @@ static void hdmi_wq_remove(struct hdmi *hdmi)
        #ifdef CONFIG_SWITCH
        switch_set_state(&(hdmi->switchdev), 0);
        #endif
-       mutex_lock(&hdmi->ddev->lock);
        list_for_each_safe(pos, n, &hdmi->edid.modelist) {
                list_del(pos);
                kfree(pos);
        }
-       mutex_unlock(&hdmi->ddev->lock);
        for (i = 0; i < HDMI_MAX_EDID_BLOCK; i++)
                kfree(hdmi->edid.raw[i]);
        kfree(hdmi->edid.audio);
@@ -290,7 +288,7 @@ static void hdmi_work_queue(struct work_struct *work)
        int event = hdmi_w->event;
        int hpd = HDMI_HPD_REMOVED;
 
-       mutex_lock(&hdmi->lock);
+       mutex_lock(&hdmi->ddev->lock);
 
        DBG("\nhdmi_work_queue() - evt= %x %d\n",
            (event & 0xFF00) >> 8,
@@ -431,7 +429,7 @@ static void hdmi_work_queue(struct work_struct *work)
        DBG("\nhdmi_work_queue() - exit evt= %x %d\n",
            (event & 0xFF00) >> 8,
            event & 0xFF);
-       mutex_unlock(&hdmi->lock);
+       mutex_unlock(&hdmi->ddev->lock);
 }
 
 struct hdmi *rockchip_hdmi_register(struct hdmi_property *property,
index 066391aaab0e2733eea28b6904ff1b2c0bad4ea2..95c95f294462eac220ff772841e12217e62a7eb8 100644 (file)
@@ -51,7 +51,6 @@ static int hdmi_set_mode(struct rk_display_device *device,
                        container_of(mode, struct display_modelist, mode);
        int vic = 0;
 
-       mutex_lock(&hdmi->lock);
        if (mode == NULL) {
                hdmi->autoset = 1;
                vic = hdmi_find_best_mode(hdmi, 0);
@@ -65,7 +64,6 @@ static int hdmi_set_mode(struct rk_display_device *device,
                if (hdmi->hotplug == HDMI_HPD_ACTIVED)
                        hdmi_submit_work(hdmi, HDMI_SET_VIDEO, 0, NULL);
        }
-       mutex_unlock(&hdmi->lock);
        return 0;
 }
 
@@ -100,7 +98,7 @@ static int hdmi_set_3dmode(struct rk_display_device *device, int mode)
 
        if (!hdmi)
                return -1;
-       mutex_lock(&hdmi->lock);
+
        modelist = &hdmi->edid.modelist;
        list_for_each(pos, modelist) {
                display_modelist =
@@ -110,7 +108,6 @@ static int hdmi_set_3dmode(struct rk_display_device *device, int mode)
                else
                        display_modelist = NULL;
        }
-       mutex_unlock(&hdmi->lock);
        if (!display_modelist)
                return -1;
 
@@ -168,7 +165,6 @@ static int hdmi_get_edidaudioinfo(struct rk_display_device *device,
                return -1;
 
        memset(audioinfo, 0x00, len);
-       mutex_lock(&hdmi->lock);
        /*printk("hdmi:edid: audio_num: %d\n", hdmi->edid.audio_num);*/
        for (i = 0; i < hdmi->edid.audio_num; i++) {
                audio = &(hdmi->edid.audio[i]);
@@ -181,7 +177,6 @@ static int hdmi_get_edidaudioinfo(struct rk_display_device *device,
                audioinfo[size] = ',';
                audioinfo += (size+1);
        }
-       mutex_unlock(&hdmi->lock);
        return 0;
 }
 
@@ -190,7 +185,6 @@ static int hdmi_get_color(struct rk_display_device *device, char *buf)
        struct hdmi *hdmi = device->priv_data;
        int i, mode;
 
-       mutex_lock(&hdmi->lock);
        mode = (1 << HDMI_COLOR_RGB_0_255);
        if (hdmi->edid.sink_hdmi) {
                mode |= (1 << HDMI_COLOR_RGB_16_235);
@@ -222,7 +216,6 @@ static int hdmi_get_color(struct rk_display_device *device, char *buf)
                      "Supported Colorimetry: %d\n", hdmi->edid.colorimetry);
        i += snprintf(buf + i, PAGE_SIZE - i,
                      "Current Colorimetry: %d\n", hdmi->colorimetry);
-       mutex_unlock(&hdmi->lock);
        return i;
 }
 
@@ -306,10 +299,8 @@ static int hdmi_get_monspecs(struct rk_display_device *device,
        if (!hdmi)
                return -1;
 
-       mutex_lock(&hdmi->lock);
        if (hdmi->edid.specs)
                *monspecs = *(hdmi->edid.specs);
-       mutex_unlock(&hdmi->lock);
        return 0;
 }
 
@@ -532,7 +523,6 @@ static int hdmi_get_debug(struct rk_display_device *device, char *buf)
        len += snprintf(buf+len, PAGE_SIZE - len, "EDID status:%s\n",
                        hdmi->edid.status ? "False" : "Okay");
        len += snprintf(buf+len, PAGE_SIZE - len, "Raw Data:");
-       mutex_lock(&hdmi->lock);
        for (i = 0; i < HDMI_MAX_EDID_BLOCK; i++) {
                if (!hdmi->edid.raw[i])
                        break;
@@ -548,7 +538,6 @@ static int hdmi_get_debug(struct rk_display_device *device, char *buf)
        len += snprintf(buf+len, PAGE_SIZE, "\n");
        if (!hdmi->edid.status)
                len += hdmi_show_sink_info(hdmi, buf, len);
-       mutex_unlock(&hdmi->lock);
        return len;
 }