hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/video/fbdev/imxfb.c
....@@ -172,6 +172,7 @@
172172 int num_modes;
173173
174174 struct regulator *lcd_pwr;
175
+ int lcd_pwr_enabled;
175176 };
176177
177178 static const struct platform_device_id imxfb_devtype[] = {
....@@ -566,7 +567,7 @@
566567 return 0;
567568 }
568569
569
-static struct fb_ops imxfb_ops = {
570
+static const struct fb_ops imxfb_ops = {
570571 .owner = THIS_MODULE,
571572 .fb_check_var = imxfb_check_var,
572573 .fb_set_par = imxfb_set_par,
....@@ -601,10 +602,10 @@
601602 if (var->hsync_len < 1 || var->hsync_len > 64)
602603 printk(KERN_ERR "%s: invalid hsync_len %d\n",
603604 info->fix.id, var->hsync_len);
604
- if (var->left_margin > 255)
605
+ if (var->left_margin < 3 || var->left_margin > 255)
605606 printk(KERN_ERR "%s: invalid left_margin %d\n",
606607 info->fix.id, var->left_margin);
607
- if (var->right_margin > 255)
608
+ if (var->right_margin < 1 || var->right_margin > 255)
608609 printk(KERN_ERR "%s: invalid right_margin %d\n",
609610 info->fix.id, var->right_margin);
610611 if (var->yres < 1 || var->yres > ymax_mask)
....@@ -801,16 +802,30 @@
801802 return FB_BLANK_UNBLANK;
802803 }
803804
805
+static int imxfb_regulator_set(struct imxfb_info *fbi, int enable)
806
+{
807
+ int ret;
808
+
809
+ if (enable == fbi->lcd_pwr_enabled)
810
+ return 0;
811
+
812
+ if (enable)
813
+ ret = regulator_enable(fbi->lcd_pwr);
814
+ else
815
+ ret = regulator_disable(fbi->lcd_pwr);
816
+
817
+ if (ret == 0)
818
+ fbi->lcd_pwr_enabled = enable;
819
+
820
+ return ret;
821
+}
822
+
804823 static int imxfb_lcd_set_power(struct lcd_device *lcddev, int power)
805824 {
806825 struct imxfb_info *fbi = dev_get_drvdata(&lcddev->dev);
807826
808
- if (!IS_ERR(fbi->lcd_pwr)) {
809
- if (power == FB_BLANK_UNBLANK)
810
- return regulator_enable(fbi->lcd_pwr);
811
- else
812
- return regulator_disable(fbi->lcd_pwr);
813
- }
827
+ if (!IS_ERR(fbi->lcd_pwr))
828
+ return imxfb_regulator_set(fbi, power == FB_BLANK_UNBLANK);
814829
815830 return 0;
816831 }
....@@ -974,11 +989,10 @@
974989 }
975990
976991 fbi->map_size = PAGE_ALIGN(info->fix.smem_len);
977
- info->screen_base = dma_alloc_wc(&pdev->dev, fbi->map_size,
978
- &fbi->map_dma, GFP_KERNEL);
979
-
980
- if (!info->screen_base) {
981
- dev_err(&pdev->dev, "Failed to allocate video RAM: %d\n", ret);
992
+ info->screen_buffer = dma_alloc_wc(&pdev->dev, fbi->map_size,
993
+ &fbi->map_dma, GFP_KERNEL);
994
+ if (!info->screen_buffer) {
995
+ dev_err(&pdev->dev, "Failed to allocate video RAM\n");
982996 ret = -ENOMEM;
983997 goto failed_map;
984998 }
....@@ -1018,7 +1032,7 @@
10181032 }
10191033
10201034 fbi->lcd_pwr = devm_regulator_get(&pdev->dev, "lcd");
1021
- if (IS_ERR(fbi->lcd_pwr) && (PTR_ERR(fbi->lcd_pwr) == -EPROBE_DEFER)) {
1035
+ if (PTR_ERR(fbi->lcd_pwr) == -EPROBE_DEFER) {
10221036 ret = -EPROBE_DEFER;
10231037 goto failed_lcd;
10241038 }
....@@ -1046,7 +1060,7 @@
10461060 if (pdata && pdata->exit)
10471061 pdata->exit(fbi->pdev);
10481062 failed_platform_init:
1049
- dma_free_wc(&pdev->dev, fbi->map_size, info->screen_base,
1063
+ dma_free_wc(&pdev->dev, fbi->map_size, info->screen_buffer,
10501064 fbi->map_dma);
10511065 failed_map:
10521066 iounmap(fbi->regs);
....@@ -1077,7 +1091,7 @@
10771091 pdata = dev_get_platdata(&pdev->dev);
10781092 if (pdata && pdata->exit)
10791093 pdata->exit(fbi->pdev);
1080
- dma_free_wc(&pdev->dev, fbi->map_size, info->screen_base,
1094
+ dma_free_wc(&pdev->dev, fbi->map_size, info->screen_buffer,
10811095 fbi->map_dma);
10821096 iounmap(fbi->regs);
10831097 release_mem_region(res->start, resource_size(res));