hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/video/fbdev/sh_mobile_lcdcfb.c
....@@ -15,6 +15,7 @@
1515 #include <linux/ctype.h>
1616 #include <linux/dma-mapping.h>
1717 #include <linux/delay.h>
18
+#include <linux/fbcon.h>
1819 #include <linux/gpio.h>
1920 #include <linux/init.h>
2021 #include <linux/interrupt.h>
....@@ -213,7 +214,6 @@
213214 struct sh_mobile_lcdc_chan ch[2];
214215 struct sh_mobile_lcdc_overlay overlays[4];
215216
216
- struct notifier_block notifier;
217217 int started;
218218 int forced_fourcc; /* 2 channel LCDC must share fourcc setting */
219219 };
....@@ -534,88 +534,8 @@
534534 ch->tx_dev->ops->display_off(ch->tx_dev);
535535 }
536536
537
-static bool
538
-sh_mobile_lcdc_must_reconfigure(struct sh_mobile_lcdc_chan *ch,
539
- const struct fb_videomode *new_mode)
540
-{
541
- dev_dbg(ch->info->dev, "Old %ux%u, new %ux%u\n",
542
- ch->display.mode.xres, ch->display.mode.yres,
543
- new_mode->xres, new_mode->yres);
544
-
545
- /* It can be a different monitor with an equal video-mode */
546
- if (fb_mode_is_equal(&ch->display.mode, new_mode))
547
- return false;
548
-
549
- dev_dbg(ch->info->dev, "Switching %u -> %u lines\n",
550
- ch->display.mode.yres, new_mode->yres);
551
- ch->display.mode = *new_mode;
552
-
553
- return true;
554
-}
555
-
556537 static int sh_mobile_lcdc_check_var(struct fb_var_screeninfo *var,
557538 struct fb_info *info);
558
-
559
-static int sh_mobile_lcdc_display_notify(struct sh_mobile_lcdc_chan *ch,
560
- enum sh_mobile_lcdc_entity_event event,
561
- const struct fb_videomode *mode,
562
- const struct fb_monspecs *monspec)
563
-{
564
- struct fb_info *info = ch->info;
565
- struct fb_var_screeninfo var;
566
- int ret = 0;
567
-
568
- switch (event) {
569
- case SH_MOBILE_LCDC_EVENT_DISPLAY_CONNECT:
570
- /* HDMI plug in */
571
- console_lock();
572
- if (lock_fb_info(info)) {
573
-
574
-
575
- ch->display.width = monspec->max_x * 10;
576
- ch->display.height = monspec->max_y * 10;
577
-
578
- if (!sh_mobile_lcdc_must_reconfigure(ch, mode) &&
579
- info->state == FBINFO_STATE_RUNNING) {
580
- /* First activation with the default monitor.
581
- * Just turn on, if we run a resume here, the
582
- * logo disappears.
583
- */
584
- info->var.width = ch->display.width;
585
- info->var.height = ch->display.height;
586
- sh_mobile_lcdc_display_on(ch);
587
- } else {
588
- /* New monitor or have to wake up */
589
- fb_set_suspend(info, 0);
590
- }
591
-
592
-
593
- unlock_fb_info(info);
594
- }
595
- console_unlock();
596
- break;
597
-
598
- case SH_MOBILE_LCDC_EVENT_DISPLAY_DISCONNECT:
599
- /* HDMI disconnect */
600
- console_lock();
601
- if (lock_fb_info(info)) {
602
- fb_set_suspend(info, 1);
603
- unlock_fb_info(info);
604
- }
605
- console_unlock();
606
- break;
607
-
608
- case SH_MOBILE_LCDC_EVENT_DISPLAY_MODE:
609
- /* Validate a proposed new mode */
610
- fb_videomode_to_var(&var, mode);
611
- var.bits_per_pixel = info->var.bits_per_pixel;
612
- var.grayscale = info->var.grayscale;
613
- ret = sh_mobile_lcdc_check_var(&var, info);
614
- break;
615
- }
616
-
617
- return ret;
618
-}
619539
620540 /* -----------------------------------------------------------------------------
621541 * Format helpers
....@@ -1570,7 +1490,7 @@
15701490 ovl->dma_handle, ovl->fb_size);
15711491 }
15721492
1573
-static struct fb_ops sh_mobile_lcdc_overlay_ops = {
1493
+static const struct fb_ops sh_mobile_lcdc_overlay_ops = {
15741494 .owner = THIS_MODULE,
15751495 .fb_read = fb_sys_read,
15761496 .fb_write = fb_sys_write,
....@@ -1644,17 +1564,15 @@
16441564
16451565 /* Allocate and initialize the frame buffer device. */
16461566 info = framebuffer_alloc(0, priv->dev);
1647
- if (info == NULL) {
1648
- dev_err(priv->dev, "unable to allocate fb_info\n");
1567
+ if (!info)
16491568 return -ENOMEM;
1650
- }
16511569
16521570 ovl->info = info;
16531571
16541572 info->flags = FBINFO_FLAG_DEFAULT;
16551573 info->fbops = &sh_mobile_lcdc_overlay_ops;
16561574 info->device = priv->dev;
1657
- info->screen_base = ovl->fb_mem;
1575
+ info->screen_buffer = ovl->fb_mem;
16581576 info->par = ovl;
16591577
16601578 /* Initialize fixed screen information. Restrict pan to 2 lines steps
....@@ -1676,6 +1594,7 @@
16761594 case V4L2_PIX_FMT_NV12:
16771595 case V4L2_PIX_FMT_NV21:
16781596 info->fix.ypanstep = 2;
1597
+ fallthrough;
16791598 case V4L2_PIX_FMT_NV16:
16801599 case V4L2_PIX_FMT_NV61:
16811600 info->fix.xpanstep = 2;
....@@ -1838,8 +1757,6 @@
18381757 struct sh_mobile_lcdc_chan *ch = info->par;
18391758 struct fb_var_screeninfo var;
18401759 struct fb_videomode mode;
1841
- struct fb_event event;
1842
- int evnt = FB_EVENT_MODE_CHANGE_ALL;
18431760
18441761 if (ch->use_count > 1 || (ch->use_count == 1 && !info->fbcon_par))
18451762 /* More framebuffer users are active */
....@@ -1861,14 +1778,7 @@
18611778 /* Couldn't reconfigure, hopefully, can continue as before */
18621779 return;
18631780
1864
- /*
1865
- * fb_set_var() calls the notifier change internally, only if
1866
- * FBINFO_MISC_USEREVENT flag is set. Since we do not want to fake a
1867
- * user event, we have to call the chain ourselves.
1868
- */
1869
- event.info = info;
1870
- event.data = &ch->display.mode;
1871
- fb_notifier_call_chain(evnt, &event);
1781
+ fbcon_update_vcs(info, true);
18721782 }
18731783
18741784 /*
....@@ -2054,7 +1964,7 @@
20541964 ch->dma_handle, ch->fb_size);
20551965 }
20561966
2057
-static struct fb_ops sh_mobile_lcdc_ops = {
1967
+static const struct fb_ops sh_mobile_lcdc_ops = {
20581968 .owner = THIS_MODULE,
20591969 .fb_setcolreg = sh_mobile_lcdc_setcolreg,
20601970 .fb_read = fb_sys_read,
....@@ -2138,17 +2048,15 @@
21382048 * list and allocate the color map.
21392049 */
21402050 info = framebuffer_alloc(0, priv->dev);
2141
- if (info == NULL) {
2142
- dev_err(priv->dev, "unable to allocate fb_info\n");
2051
+ if (!info)
21432052 return -ENOMEM;
2144
- }
21452053
21462054 ch->info = info;
21472055
21482056 info->flags = FBINFO_FLAG_DEFAULT;
21492057 info->fbops = &sh_mobile_lcdc_ops;
21502058 info->device = priv->dev;
2151
- info->screen_base = ch->fb_mem;
2059
+ info->screen_buffer = ch->fb_mem;
21522060 info->pseudo_palette = &ch->pseudo_palette;
21532061 info->par = ch;
21542062
....@@ -2177,6 +2085,7 @@
21772085 case V4L2_PIX_FMT_NV12:
21782086 case V4L2_PIX_FMT_NV21:
21792087 info->fix.ypanstep = 2;
2088
+ fallthrough;
21802089 case V4L2_PIX_FMT_NV16:
21812090 case V4L2_PIX_FMT_NV61:
21822091 info->fix.xpanstep = 2;
....@@ -2319,37 +2228,6 @@
23192228 * Framebuffer notifier
23202229 */
23212230
2322
-/* locking: called with info->lock held */
2323
-static int sh_mobile_lcdc_notify(struct notifier_block *nb,
2324
- unsigned long action, void *data)
2325
-{
2326
- struct fb_event *event = data;
2327
- struct fb_info *info = event->info;
2328
- struct sh_mobile_lcdc_chan *ch = info->par;
2329
-
2330
- if (&ch->lcdc->notifier != nb)
2331
- return NOTIFY_DONE;
2332
-
2333
- dev_dbg(info->dev, "%s(): action = %lu, data = %p\n",
2334
- __func__, action, event->data);
2335
-
2336
- switch(action) {
2337
- case FB_EVENT_SUSPEND:
2338
- sh_mobile_lcdc_display_off(ch);
2339
- sh_mobile_lcdc_stop(ch->lcdc);
2340
- break;
2341
- case FB_EVENT_RESUME:
2342
- mutex_lock(&ch->open_lock);
2343
- sh_mobile_fb_reconfig(info);
2344
- mutex_unlock(&ch->open_lock);
2345
-
2346
- sh_mobile_lcdc_display_on(ch);
2347
- sh_mobile_lcdc_start(ch->lcdc);
2348
- }
2349
-
2350
- return NOTIFY_OK;
2351
-}
2352
-
23532231 /* -----------------------------------------------------------------------------
23542232 * Probe/remove and driver init/exit
23552233 */
....@@ -2376,8 +2254,6 @@
23762254 {
23772255 struct sh_mobile_lcdc_priv *priv = platform_get_drvdata(pdev);
23782256 unsigned int i;
2379
-
2380
- fb_unregister_client(&priv->notifier);
23812257
23822258 for (i = 0; i < ARRAY_SIZE(priv->overlays); i++)
23832259 sh_mobile_lcdc_overlay_fb_unregister(&priv->overlays[i]);
....@@ -2539,8 +2415,6 @@
25392415 unsigned int num_modes;
25402416 unsigned int max_size;
25412417 unsigned int i;
2542
-
2543
- ch->notify = sh_mobile_lcdc_display_notify;
25442418
25452419 /* Validate the format. */
25462420 format = sh_mobile_format_info(cfg->fourcc);
....@@ -2714,7 +2588,7 @@
27142588 if (num_channels == 2)
27152589 priv->forced_fourcc = pdata->ch[0].fourcc;
27162590
2717
- priv->base = ioremap_nocache(res->start, resource_size(res));
2591
+ priv->base = ioremap(res->start, resource_size(res));
27182592 if (!priv->base) {
27192593 error = -ENOMEM;
27202594 goto err1;
....@@ -2769,10 +2643,6 @@
27692643 if (error)
27702644 goto err1;
27712645 }
2772
-
2773
- /* Failure ignored */
2774
- priv->notifier.notifier_call = sh_mobile_lcdc_notify;
2775
- fb_register_client(&priv->notifier);
27762646
27772647 return 0;
27782648 err1: