aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2010-09-03 03:20:31 -0400
committerPaul Mundt <lethal@linux-sh.org>2010-09-14 04:23:30 -0400
commit6aa966e610f918a6732a5acc102cb5e8de616cb3 (patch)
tree622336fd1183b50e67ea04e552757368b363dd2c /drivers/video
parent1c120deb60edd4c19a2109daa98f65f2ad3b9c06 (diff)
fbdev: sh_mobile_hdmi: cosmetic improvements
Improve comments, unify function names, replace pr_debug with dev_dbg. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/sh_mobile_hdmi.c82
1 files changed, 45 insertions, 37 deletions
diff --git a/drivers/video/sh_mobile_hdmi.c b/drivers/video/sh_mobile_hdmi.c
index 51ce34990e24..91682f1bad79 100644
--- a/drivers/video/sh_mobile_hdmi.c
+++ b/drivers/video/sh_mobile_hdmi.c
@@ -206,7 +206,7 @@ enum hotplug_state {
206 206
207struct sh_hdmi { 207struct sh_hdmi {
208 void __iomem *base; 208 void __iomem *base;
209 enum hotplug_state hp_state; 209 enum hotplug_state hp_state; /* hot-plug status */
210 bool preprogrammed_mode; /* use a pre-programmed VIC or the external mode */ 210 bool preprogrammed_mode; /* use a pre-programmed VIC or the external mode */
211 struct clk *hdmi_clk; 211 struct clk *hdmi_clk;
212 struct device *dev; 212 struct device *dev;
@@ -227,7 +227,7 @@ static u8 hdmi_read(struct sh_hdmi *hdmi, u8 reg)
227} 227}
228 228
229/* External video parameter settings */ 229/* External video parameter settings */
230static void hdmi_external_video_param(struct sh_hdmi *hdmi) 230static void sh_hdmi_external_video_param(struct sh_hdmi *hdmi)
231{ 231{
232 struct fb_var_screeninfo *var = &hdmi->var; 232 struct fb_var_screeninfo *var = &hdmi->var;
233 u16 htotal, hblank, hdelay, vtotal, vblank, vdelay, voffset; 233 u16 htotal, hblank, hdelay, vtotal, vblank, vdelay, voffset;
@@ -259,9 +259,9 @@ static void hdmi_external_video_param(struct sh_hdmi *hdmi)
259 if (var->sync & FB_SYNC_VERT_HIGH_ACT) 259 if (var->sync & FB_SYNC_VERT_HIGH_ACT)
260 sync |= 8; 260 sync |= 8;
261 261
262 pr_debug("H: %u, %u, %u, %u; V: %u, %u, %u, %u; sync 0x%x\n", 262 dev_dbg(hdmi->dev, "H: %u, %u, %u, %u; V: %u, %u, %u, %u; sync 0x%x\n",
263 htotal, hblank, hdelay, var->hsync_len, 263 htotal, hblank, hdelay, var->hsync_len,
264 vtotal, vblank, vdelay, var->vsync_len, sync); 264 vtotal, vblank, vdelay, var->vsync_len, sync);
265 265
266 hdmi_write(hdmi, sync | (voffset << 4), HDMI_EXTERNAL_VIDEO_PARAM_SETTINGS); 266 hdmi_write(hdmi, sync | (voffset << 4), HDMI_EXTERNAL_VIDEO_PARAM_SETTINGS);
267 267
@@ -476,9 +476,9 @@ static void sh_hdmi_avi_infoframe_setup(struct sh_hdmi *hdmi)
476 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB1); 476 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB1);
477 477
478 /* 478 /*
479 * C = No Data 479 * [7:6] C = Colorimetry: no data
480 * M = 16:9 Picture Aspect Ratio 480 * [5:4] M = 2: 16:9, 1: 4:3 Picture Aspect Ratio
481 * R = Same as picture aspect ratio 481 * [3:0] R = 8: Active Frame Aspect Ratio: same as picture aspect ratio
482 */ 482 */
483 hdmi_write(hdmi, 0x28, HDMI_CTRL_PKT_BUF_ACCESS_PB2); 483 hdmi_write(hdmi, 0x28, HDMI_CTRL_PKT_BUF_ACCESS_PB2);
484 484
@@ -619,7 +619,7 @@ static void sh_hdmi_read_edid(struct sh_hdmi *hdmi)
619 u8 edid[128]; 619 u8 edid[128];
620 620
621 /* Read EDID */ 621 /* Read EDID */
622 pr_debug("Read back EDID code:"); 622 dev_dbg(hdmi->dev, "Read back EDID code:");
623 for (i = 0; i < 128; i++) { 623 for (i = 0; i < 128; i++) {
624 edid[i] = hdmi_read(hdmi, HDMI_EDID_KSV_FIFO_ACCESS_WINDOW); 624 edid[i] = hdmi_read(hdmi, HDMI_EDID_KSV_FIFO_ACCESS_WINDOW);
625#ifdef DEBUG 625#ifdef DEBUG
@@ -635,10 +635,10 @@ static void sh_hdmi_read_edid(struct sh_hdmi *hdmi)
635 printk(KERN_CONT "\n"); 635 printk(KERN_CONT "\n");
636#endif 636#endif
637 fb_parse_edid(edid, var); 637 fb_parse_edid(edid, var);
638 pr_debug("%u-%u-%u-%u x %u-%u-%u-%u @ %lu kHz monitor detected\n", 638 dev_dbg(hdmi->dev, "%u-%u-%u-%u x %u-%u-%u-%u @ %lu kHz monitor detected\n",
639 var->left_margin, var->xres, var->right_margin, var->hsync_len, 639 var->left_margin, var->xres, var->right_margin, var->hsync_len,
640 var->upper_margin, var->yres, var->lower_margin, var->vsync_len, 640 var->upper_margin, var->yres, var->lower_margin, var->vsync_len,
641 PICOS2KHZ(var->pixclock)); 641 PICOS2KHZ(var->pixclock));
642 642
643 if ((hdmi->var.xres == 720 && hdmi->var.yres == 480) || 643 if ((hdmi->var.xres == 720 && hdmi->var.yres == 480) ||
644 (hdmi->var.xres == 1280 && hdmi->var.yres == 720) || 644 (hdmi->var.xres == 1280 && hdmi->var.yres == 720) ||
@@ -647,7 +647,7 @@ static void sh_hdmi_read_edid(struct sh_hdmi *hdmi)
647 else 647 else
648 hdmi->preprogrammed_mode = false; 648 hdmi->preprogrammed_mode = false;
649 649
650 hdmi_external_video_param(hdmi); 650 sh_hdmi_external_video_param(hdmi);
651} 651}
652 652
653static irqreturn_t sh_hdmi_hotplug(int irq, void *dev_id) 653static irqreturn_t sh_hdmi_hotplug(int irq, void *dev_id)
@@ -675,8 +675,8 @@ static irqreturn_t sh_hdmi_hotplug(int irq, void *dev_id)
675 hdmi_write(hdmi, 0xFF, HDMI_INTERRUPT_STATUS_2); 675 hdmi_write(hdmi, 0xFF, HDMI_INTERRUPT_STATUS_2);
676 676
677 if (printk_ratelimit()) 677 if (printk_ratelimit())
678 pr_debug("IRQ #%d: Status #1: 0x%x & 0x%x, #2: 0x%x & 0x%x\n", 678 dev_dbg(hdmi->dev, "IRQ #%d: Status #1: 0x%x & 0x%x, #2: 0x%x & 0x%x\n",
679 irq, status1, mask1, status2, mask2); 679 irq, status1, mask1, status2, mask2);
680 680
681 if (!((status1 & mask1) | (status2 & mask2))) { 681 if (!((status1 & mask1) | (status2 & mask2))) {
682 return IRQ_NONE; 682 return IRQ_NONE;
@@ -687,7 +687,7 @@ static irqreturn_t sh_hdmi_hotplug(int irq, void *dev_id)
687 udelay(500); 687 udelay(500);
688 688
689 msens = hdmi_read(hdmi, HDMI_HOT_PLUG_MSENS_STATUS); 689 msens = hdmi_read(hdmi, HDMI_HOT_PLUG_MSENS_STATUS);
690 pr_debug("MSENS 0x%x\n", msens); 690 dev_dbg(hdmi->dev, "MSENS 0x%x\n", msens);
691 /* Check, if hot plug & MSENS pin status are both high */ 691 /* Check, if hot plug & MSENS pin status are both high */
692 if ((msens & 0xC0) == 0xC0) { 692 if ((msens & 0xC0) == 0xC0) {
693 /* Display plug in */ 693 /* Display plug in */
@@ -724,7 +724,7 @@ static irqreturn_t sh_hdmi_hotplug(int irq, void *dev_id)
724} 724}
725 725
726/* locking: called with info->lock held, or before register_framebuffer() */ 726/* locking: called with info->lock held, or before register_framebuffer() */
727static void hdmi_display_on(void *arg, struct fb_info *info) 727static void sh_hdmi_display_on(void *arg, struct fb_info *info)
728{ 728{
729 /* 729 /*
730 * info is guaranteed to be valid, when we are called, because our 730 * info is guaranteed to be valid, when we are called, because our
@@ -734,16 +734,23 @@ static void hdmi_display_on(void *arg, struct fb_info *info)
734 struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data; 734 struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data;
735 struct sh_mobile_lcdc_chan *ch = info->par; 735 struct sh_mobile_lcdc_chan *ch = info->par;
736 736
737 pr_debug("%s(%p): state %x\n", __func__, pdata->lcd_dev, info->state); 737 dev_dbg(hdmi->dev, "%s(%p): state %x\n", __func__,
738 pdata->lcd_dev, info->state);
738 739
739 /* No need to lock */ 740 /* No need to lock */
740 hdmi->info = info; 741 hdmi->info = info;
741 742
743 /*
744 * hp_state can be set to
745 * HDMI_HOTPLUG_DISCONNECTED: on monitor unplug
746 * HDMI_HOTPLUG_CONNECTED: on monitor plug-in
747 * HDMI_HOTPLUG_EDID_DONE: on EDID read completion
748 */
742 switch (hdmi->hp_state) { 749 switch (hdmi->hp_state) {
743 case HDMI_HOTPLUG_EDID_DONE: 750 case HDMI_HOTPLUG_EDID_DONE:
744 /* PS mode d->e. All functions are active */ 751 /* PS mode d->e. All functions are active */
745 hdmi_write(hdmi, 0x80, HDMI_SYSTEM_CTRL); 752 hdmi_write(hdmi, 0x80, HDMI_SYSTEM_CTRL);
746 pr_debug("HDMI running\n"); 753 dev_dbg(hdmi->dev, "HDMI running\n");
747 break; 754 break;
748 case HDMI_HOTPLUG_DISCONNECTED: 755 case HDMI_HOTPLUG_DISCONNECTED:
749 info->state = FBINFO_STATE_SUSPENDED; 756 info->state = FBINFO_STATE_SUSPENDED;
@@ -753,25 +760,25 @@ static void hdmi_display_on(void *arg, struct fb_info *info)
753} 760}
754 761
755/* locking: called with info->lock held */ 762/* locking: called with info->lock held */
756static void hdmi_display_off(void *arg) 763static void sh_hdmi_display_off(void *arg)
757{ 764{
758 struct sh_hdmi *hdmi = arg; 765 struct sh_hdmi *hdmi = arg;
759 struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data; 766 struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data;
760 767
761 pr_debug("%s(%p)\n", __func__, pdata->lcd_dev); 768 dev_dbg(hdmi->dev, "%s(%p)\n", __func__, pdata->lcd_dev);
762 /* PS mode e->a */ 769 /* PS mode e->a */
763 hdmi_write(hdmi, 0x10, HDMI_SYSTEM_CTRL); 770 hdmi_write(hdmi, 0x10, HDMI_SYSTEM_CTRL);
764} 771}
765 772
766/* Hotplug interrupt occurred, read EDID */ 773/* Hotplug interrupt occurred, read EDID */
767static void edid_work_fn(struct work_struct *work) 774static void sh_hdmi_edid_work_fn(struct work_struct *work)
768{ 775{
769 struct sh_hdmi *hdmi = container_of(work, struct sh_hdmi, edid_work.work); 776 struct sh_hdmi *hdmi = container_of(work, struct sh_hdmi, edid_work.work);
770 struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data; 777 struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data;
771 struct sh_mobile_lcdc_chan *ch; 778 struct sh_mobile_lcdc_chan *ch;
772 779
773 pr_debug("%s(%p): begin, hotplug status %d\n", __func__, 780 dev_dbg(hdmi->dev, "%s(%p): begin, hotplug status %d\n", __func__,
774 pdata->lcd_dev, hdmi->hp_state); 781 pdata->lcd_dev, hdmi->hp_state);
775 782
776 if (!pdata->lcd_dev) 783 if (!pdata->lcd_dev)
777 return; 784 return;
@@ -800,7 +807,7 @@ static void edid_work_fn(struct work_struct *work)
800 fb_set_suspend(hdmi->info, 0); 807 fb_set_suspend(hdmi->info, 0);
801 } else { 808 } else {
802 if (lock_fb_info(hdmi->info)) { 809 if (lock_fb_info(hdmi->info)) {
803 hdmi_display_on(hdmi, hdmi->info); 810 sh_hdmi_display_on(hdmi, hdmi->info);
804 unlock_fb_info(hdmi->info); 811 unlock_fb_info(hdmi->info);
805 } 812 }
806 } 813 }
@@ -822,7 +829,7 @@ static void edid_work_fn(struct work_struct *work)
822out: 829out:
823 mutex_unlock(&hdmi->mutex); 830 mutex_unlock(&hdmi->mutex);
824 831
825 pr_debug("%s(%p): end\n", __func__, pdata->lcd_dev); 832 dev_dbg(hdmi->dev, "%s(%p): end\n", __func__, pdata->lcd_dev);
826} 833}
827 834
828static int sh_hdmi_notify(struct notifier_block *nb, 835static int sh_hdmi_notify(struct notifier_block *nb,
@@ -846,18 +853,19 @@ static int sh_hdmi_notify(struct notifier_block *nb,
846 853
847 switch(action) { 854 switch(action) {
848 case FB_EVENT_FB_REGISTERED: 855 case FB_EVENT_FB_REGISTERED:
849 /* Unneeded, activation taken care by hdmi_display_on() */ 856 /* Unneeded, activation taken care by sh_hdmi_display_on() */
850 break; 857 break;
851 case FB_EVENT_FB_UNREGISTERED: 858 case FB_EVENT_FB_UNREGISTERED:
852 /* 859 /*
853 * We are called from unregister_framebuffer() with the 860 * We are called from unregister_framebuffer() with the
854 * info->lock held. This is bad for us, because we can race with 861 * info->lock held. This is bad for us, because we can race with
855 * the scheduled work, which has to call fb_set_suspend(), which 862 * the scheduled work, which has to call fb_set_suspend(), which
856 * takes info->lock internally, so, edid_work_fn() cannot take 863 * takes info->lock internally, so, sh_hdmi_edid_work_fn()
857 * and hold info->lock for the whole function duration. Using an 864 * cannot take and hold info->lock for the whole function
858 * additional lock creates a classical AB-BA lock up. Therefore, 865 * duration. Using an additional lock creates a classical AB-BA
859 * we have to release the info->lock temporarily, synchronise 866 * lock up. Therefore, we have to release the info->lock
860 * with the work queue and re-acquire the info->lock. 867 * temporarily, synchronise with the work queue and re-acquire
868 * the info->lock.
861 */ 869 */
862 unlock_fb_info(hdmi->info); 870 unlock_fb_info(hdmi->info);
863 mutex_lock(&hdmi->mutex); 871 mutex_lock(&hdmi->mutex);
@@ -913,7 +921,7 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
913 goto erate; 921 goto erate;
914 } 922 }
915 923
916 pr_debug("HDMI set frequency %lu\n", rate); 924 dev_dbg(hdmi->dev, "HDMI set frequency %lu\n", rate);
917 925
918 ret = clk_enable(hdmi->hdmi_clk); 926 ret = clk_enable(hdmi->hdmi_clk);
919 if (ret < 0) { 927 if (ret < 0) {
@@ -948,10 +956,10 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
948 board_cfg = &pdata->lcd_chan->board_cfg; 956 board_cfg = &pdata->lcd_chan->board_cfg;
949 board_cfg->owner = THIS_MODULE; 957 board_cfg->owner = THIS_MODULE;
950 board_cfg->board_data = hdmi; 958 board_cfg->board_data = hdmi;
951 board_cfg->display_on = hdmi_display_on; 959 board_cfg->display_on = sh_hdmi_display_on;
952 board_cfg->display_off = hdmi_display_off; 960 board_cfg->display_off = sh_hdmi_display_off;
953 961
954 INIT_DELAYED_WORK(&hdmi->edid_work, edid_work_fn); 962 INIT_DELAYED_WORK(&hdmi->edid_work, sh_hdmi_edid_work_fn);
955 963
956 pm_runtime_enable(&pdev->dev); 964 pm_runtime_enable(&pdev->dev);
957 pm_runtime_resume(&pdev->dev); 965 pm_runtime_resume(&pdev->dev);