Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fbdev: sh_mobile_lcdc: Don't store copy of platform data

Instead of copying the whole platform data structure to struct
sh_mobile_lcdc_chan, store a const pointer to the channel platform data.

MERAM configuration information needs to be changed at runtime, so copy
it to struct sh_mobile_lcdc_chan.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

+38 -38
+35 -36
drivers/video/sh_mobile_lcdcfb.c
··· 116 116 117 117 static int lcdc_chan_is_sublcd(struct sh_mobile_lcdc_chan *chan) 118 118 { 119 - return chan->cfg.chan == LCDC_CHAN_SUBLCD; 119 + return chan->cfg->chan == LCDC_CHAN_SUBLCD; 120 120 } 121 121 122 122 static void lcdc_write_chan(struct sh_mobile_lcdc_chan *chan, ··· 289 289 struct list_head *pagelist) 290 290 { 291 291 struct sh_mobile_lcdc_chan *ch = info->par; 292 - struct sh_mobile_lcdc_panel_cfg *panel = &ch->cfg.panel_cfg; 292 + const struct sh_mobile_lcdc_panel_cfg *panel = &ch->cfg->panel_cfg; 293 293 294 294 /* enable clocks before accessing hardware */ 295 295 sh_mobile_lcdc_clk_on(ch->lcdc); ··· 336 336 337 337 static void sh_mobile_lcdc_display_on(struct sh_mobile_lcdc_chan *ch) 338 338 { 339 - struct sh_mobile_lcdc_panel_cfg *panel = &ch->cfg.panel_cfg; 339 + const struct sh_mobile_lcdc_panel_cfg *panel = &ch->cfg->panel_cfg; 340 340 341 341 if (ch->tx_dev) { 342 342 int ret; ··· 356 356 357 357 static void sh_mobile_lcdc_display_off(struct sh_mobile_lcdc_chan *ch) 358 358 { 359 - struct sh_mobile_lcdc_panel_cfg *panel = &ch->cfg.panel_cfg; 359 + const struct sh_mobile_lcdc_panel_cfg *panel = &ch->cfg->panel_cfg; 360 360 361 361 if (panel->display_off) 362 362 panel->display_off(); ··· 644 644 tmp = ch->ldmt1r_value; 645 645 tmp |= (var->sync & FB_SYNC_VERT_HIGH_ACT) ? 0 : LDMT1R_VPOL; 646 646 tmp |= (var->sync & FB_SYNC_HOR_HIGH_ACT) ? 0 : LDMT1R_HPOL; 647 - tmp |= (ch->cfg.flags & LCDC_FLAGS_DWPOL) ? LDMT1R_DWPOL : 0; 648 - tmp |= (ch->cfg.flags & LCDC_FLAGS_DIPOL) ? LDMT1R_DIPOL : 0; 649 - tmp |= (ch->cfg.flags & LCDC_FLAGS_DAPOL) ? LDMT1R_DAPOL : 0; 650 - tmp |= (ch->cfg.flags & LCDC_FLAGS_HSCNT) ? LDMT1R_HSCNT : 0; 651 - tmp |= (ch->cfg.flags & LCDC_FLAGS_DWCNT) ? LDMT1R_DWCNT : 0; 647 + tmp |= (ch->cfg->flags & LCDC_FLAGS_DWPOL) ? LDMT1R_DWPOL : 0; 648 + tmp |= (ch->cfg->flags & LCDC_FLAGS_DIPOL) ? LDMT1R_DIPOL : 0; 649 + tmp |= (ch->cfg->flags & LCDC_FLAGS_DAPOL) ? LDMT1R_DAPOL : 0; 650 + tmp |= (ch->cfg->flags & LCDC_FLAGS_HSCNT) ? LDMT1R_HSCNT : 0; 651 + tmp |= (ch->cfg->flags & LCDC_FLAGS_DWCNT) ? LDMT1R_DWCNT : 0; 652 652 lcdc_write_chan(ch, LDMT1R, tmp); 653 653 654 654 /* setup SYS bus */ 655 - lcdc_write_chan(ch, LDMT2R, ch->cfg.sys_bus_cfg.ldmt2r); 656 - lcdc_write_chan(ch, LDMT3R, ch->cfg.sys_bus_cfg.ldmt3r); 655 + lcdc_write_chan(ch, LDMT2R, ch->cfg->sys_bus_cfg.ldmt2r); 656 + lcdc_write_chan(ch, LDMT3R, ch->cfg->sys_bus_cfg.ldmt3r); 657 657 658 658 /* horizontal configuration */ 659 659 h_total = mode->xres + mode->hsync_len + mode->left_margin ··· 717 717 /* Power supply */ 718 718 lcdc_write_chan(ch, LDPMR, 0); 719 719 720 - m = ch->cfg.clock_divider; 720 + m = ch->cfg->clock_divider; 721 721 if (!m) 722 722 continue; 723 723 ··· 768 768 * continuous read mode. 769 769 */ 770 770 if (ch->ldmt1r_value & LDMT1R_IFM && 771 - ch->cfg.sys_bus_cfg.deferred_io_msec) { 771 + ch->cfg->sys_bus_cfg.deferred_io_msec) { 772 772 lcdc_write_chan(ch, LDSM1R, LDSM1R_OS); 773 773 lcdc_write(priv, _LDINTR, LDINTR_FE); 774 774 } else { ··· 822 822 lcdc_wait_bit(priv, _LDCNT2R, LDCNT2R_BR, 0); 823 823 824 824 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { 825 - struct sh_mobile_lcdc_panel_cfg *panel; 825 + const struct sh_mobile_lcdc_panel_cfg *panel; 826 826 827 827 ch = &priv->ch[k]; 828 828 if (!ch->enabled) 829 829 continue; 830 830 831 - panel = &ch->cfg.panel_cfg; 831 + panel = &ch->cfg->panel_cfg; 832 832 if (panel->setup_sys) { 833 833 ret = panel->setup_sys(ch, &sh_mobile_lcdc_sys_bus_ops); 834 834 if (ret) ··· 838 838 839 839 /* Compute frame buffer base address and pitch for each channel. */ 840 840 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { 841 - struct sh_mobile_meram_cfg *cfg; 842 841 int pixelformat; 843 842 void *meram; 844 843 ··· 849 850 ch->base_addr_c = ch->base_addr_y + ch->xres * ch->yres_virtual; 850 851 851 852 /* Enable MERAM if possible. */ 852 - cfg = ch->cfg.meram_cfg; 853 - if (mdev == NULL || mdev->ops == NULL || cfg == NULL) 853 + if (mdev == NULL || mdev->ops == NULL || 854 + ch->cfg->meram_cfg == NULL) 854 855 continue; 855 856 856 857 /* we need to de-init configured ICBs before we can ··· 880 881 break; 881 882 } 882 883 883 - meram = mdev->ops->meram_register(mdev, cfg, ch->pitch, 884 - ch->yres, pixelformat, 884 + meram = mdev->ops->meram_register(mdev, ch->cfg->meram_cfg, 885 + ch->pitch, ch->yres, pixelformat, 885 886 ch->base_addr_y, ch->base_addr_c, 886 887 &ch->base_addr_y, &ch->base_addr_c, 887 888 &ch->pitch); ··· 900 901 if (!ch->enabled) 901 902 continue; 902 903 903 - tmp = ch->cfg.sys_bus_cfg.deferred_io_msec; 904 + tmp = ch->cfg->sys_bus_cfg.deferred_io_msec; 904 905 if (ch->ldmt1r_value & LDMT1R_IFM && tmp) { 905 906 ch->defio.deferred_io = sh_mobile_lcdc_deferred_io; 906 907 ch->defio.delay = msecs_to_jiffies(tmp); ··· 1209 1210 * distance between two modes is defined as the size of the 1210 1211 * non-overlapping parts of the two rectangles. 1211 1212 */ 1212 - for (i = 0; i < ch->cfg.num_modes; ++i) { 1213 - const struct fb_videomode *mode = &ch->cfg.lcd_modes[i]; 1213 + for (i = 0; i < ch->cfg->num_modes; ++i) { 1214 + const struct fb_videomode *mode = &ch->cfg->lcd_modes[i]; 1214 1215 unsigned int dist; 1215 1216 1216 1217 /* We can only round up. */ ··· 1229 1230 } 1230 1231 1231 1232 /* If no available mode can be used, return an error. */ 1232 - if (ch->cfg.num_modes != 0) { 1233 + if (ch->cfg->num_modes != 0) { 1233 1234 if (best_dist == (unsigned int)-1) 1234 1235 return -EINVAL; 1235 1236 ··· 1439 1440 return ret; 1440 1441 1441 1442 dev_info(ch->lcdc->dev, "registered %s/%s as %dx%d %dbpp.\n", 1442 - dev_name(ch->lcdc->dev), (ch->cfg.chan == LCDC_CHAN_MAINLCD) ? 1443 + dev_name(ch->lcdc->dev), (ch->cfg->chan == LCDC_CHAN_MAINLCD) ? 1443 1444 "mainlcd" : "sublcd", info->var.xres, info->var.yres, 1444 1445 info->var.bits_per_pixel); 1445 1446 ··· 1524 1525 */ 1525 1526 var = &info->var; 1526 1527 fb_videomode_to_var(var, mode); 1527 - var->width = ch->cfg.panel_cfg.width; 1528 - var->height = ch->cfg.panel_cfg.height; 1528 + var->width = ch->cfg->panel_cfg.width; 1529 + var->height = ch->cfg->panel_cfg.height; 1529 1530 var->yres_virtual = var->yres * 2; 1530 1531 var->activate = FB_ACTIVATE_NOW; 1531 1532 ··· 1557 1558 bdev->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK)) 1558 1559 brightness = 0; 1559 1560 1560 - return ch->cfg.bl_info.set_brightness(brightness); 1561 + return ch->cfg->bl_info.set_brightness(brightness); 1561 1562 } 1562 1563 1563 1564 static int sh_mobile_lcdc_get_brightness(struct backlight_device *bdev) 1564 1565 { 1565 1566 struct sh_mobile_lcdc_chan *ch = bl_get_data(bdev); 1566 1567 1567 - return ch->cfg.bl_info.get_brightness(); 1568 + return ch->cfg->bl_info.get_brightness(); 1568 1569 } 1569 1570 1570 1571 static int sh_mobile_lcdc_check_fb(struct backlight_device *bdev, ··· 1585 1586 { 1586 1587 struct backlight_device *bl; 1587 1588 1588 - bl = backlight_device_register(ch->cfg.bl_info.name, parent, ch, 1589 + bl = backlight_device_register(ch->cfg->bl_info.name, parent, ch, 1589 1590 &sh_mobile_lcdc_bl_ops, NULL); 1590 1591 if (IS_ERR(bl)) { 1591 1592 dev_err(parent, "unable to register backlight device: %ld\n", ··· 1593 1594 return NULL; 1594 1595 } 1595 1596 1596 - bl->props.max_brightness = ch->cfg.bl_info.max_brightness; 1597 + bl->props.max_brightness = ch->cfg->bl_info.max_brightness; 1597 1598 bl->props.brightness = bl->props.max_brightness; 1598 1599 backlight_update_status(bl); 1599 1600 ··· 1726 1727 1727 1728 if (ch->tx_dev) { 1728 1729 ch->tx_dev->lcdc = NULL; 1729 - module_put(ch->cfg.tx_dev->dev.driver->owner); 1730 + module_put(ch->cfg->tx_dev->dev.driver->owner); 1730 1731 } 1731 1732 1732 1733 sh_mobile_lcdc_channel_fb_cleanup(ch); ··· 1757 1758 1758 1759 static int __devinit sh_mobile_lcdc_check_interface(struct sh_mobile_lcdc_chan *ch) 1759 1760 { 1760 - int interface_type = ch->cfg.interface_type; 1761 + int interface_type = ch->cfg->interface_type; 1761 1762 1762 1763 switch (interface_type) { 1763 1764 case RGB8: ··· 1800 1801 struct sh_mobile_lcdc_chan *ch) 1801 1802 { 1802 1803 const struct sh_mobile_lcdc_format_info *format; 1803 - struct sh_mobile_lcdc_chan_cfg *cfg = &ch->cfg; 1804 + const struct sh_mobile_lcdc_chan_cfg *cfg = ch->cfg; 1804 1805 const struct fb_videomode *max_mode; 1805 1806 const struct fb_videomode *mode; 1806 1807 unsigned int num_modes; ··· 1943 1944 struct sh_mobile_lcdc_chan *ch = priv->ch + num_channels; 1944 1945 1945 1946 ch->lcdc = priv; 1946 - memcpy(&ch->cfg, &pdata->ch[i], sizeof(pdata->ch[i])); 1947 + ch->cfg = &pdata->ch[i]; 1947 1948 1948 1949 error = sh_mobile_lcdc_check_interface(ch); 1949 1950 if (error) { ··· 1955 1956 ch->pan_offset = 0; 1956 1957 1957 1958 /* probe the backlight is there is one defined */ 1958 - if (ch->cfg.bl_info.max_brightness) 1959 + if (ch->cfg->bl_info.max_brightness) 1959 1960 ch->bl = sh_mobile_lcdc_bl_probe(&pdev->dev, ch); 1960 1961 1961 1962 switch (pdata->ch[i].chan) {
+2 -1
drivers/video/sh_mobile_lcdcfb.h
··· 54 54 struct sh_mobile_lcdc_chan { 55 55 struct sh_mobile_lcdc_priv *lcdc; 56 56 struct sh_mobile_lcdc_entity *tx_dev; 57 - struct sh_mobile_lcdc_chan_cfg cfg; 57 + const struct sh_mobile_lcdc_chan_cfg *cfg; 58 58 59 59 unsigned long *reg_offs; 60 60 unsigned long ldmt1r_value; ··· 66 66 67 67 void *fb_mem; 68 68 unsigned long fb_size; 69 + 69 70 dma_addr_t dma_handle; 70 71 unsigned long pan_offset; 71 72
+1 -1
include/video/sh_mobile_lcdc.h
··· 178 178 struct sh_mobile_lcdc_panel_cfg panel_cfg; 179 179 struct sh_mobile_lcdc_bl_info bl_info; 180 180 struct sh_mobile_lcdc_sys_bus_cfg sys_bus_cfg; /* only for SYSn I/F */ 181 - struct sh_mobile_meram_cfg *meram_cfg; 181 + const struct sh_mobile_meram_cfg *meram_cfg; 182 182 183 183 struct platform_device *tx_dev; /* HDMI/DSI transmitter device */ 184 184 };