Lines Matching refs:ch
214 struct sh_mobile_lcdc_chan ch[2]; member
407 struct sh_mobile_lcdc_chan *ch = handle; in lcdc_sys_write_index() local
409 lcdc_write(ch->lcdc, _LDDWD0R, data | LDDWDxR_WDACT); in lcdc_sys_write_index()
410 lcdc_wait_bit(ch->lcdc, _LDSR, LDSR_AS, 0); in lcdc_sys_write_index()
411 lcdc_write(ch->lcdc, _LDDWAR, LDDWAR_WA | in lcdc_sys_write_index()
412 (lcdc_chan_is_sublcd(ch) ? 2 : 0)); in lcdc_sys_write_index()
413 lcdc_wait_bit(ch->lcdc, _LDSR, LDSR_AS, 0); in lcdc_sys_write_index()
418 struct sh_mobile_lcdc_chan *ch = handle; in lcdc_sys_write_data() local
420 lcdc_write(ch->lcdc, _LDDWD0R, data | LDDWDxR_WDACT | LDDWDxR_RSW); in lcdc_sys_write_data()
421 lcdc_wait_bit(ch->lcdc, _LDSR, LDSR_AS, 0); in lcdc_sys_write_data()
422 lcdc_write(ch->lcdc, _LDDWAR, LDDWAR_WA | in lcdc_sys_write_data()
423 (lcdc_chan_is_sublcd(ch) ? 2 : 0)); in lcdc_sys_write_data()
424 lcdc_wait_bit(ch->lcdc, _LDSR, LDSR_AS, 0); in lcdc_sys_write_data()
429 struct sh_mobile_lcdc_chan *ch = handle; in lcdc_sys_read_data() local
431 lcdc_write(ch->lcdc, _LDDRDR, LDDRDR_RSR); in lcdc_sys_read_data()
432 lcdc_wait_bit(ch->lcdc, _LDSR, LDSR_AS, 0); in lcdc_sys_read_data()
433 lcdc_write(ch->lcdc, _LDDRAR, LDDRAR_RA | in lcdc_sys_read_data()
434 (lcdc_chan_is_sublcd(ch) ? 2 : 0)); in lcdc_sys_read_data()
436 lcdc_wait_bit(ch->lcdc, _LDSR, LDSR_AS, 0); in lcdc_sys_read_data()
438 return lcdc_read(ch->lcdc, _LDDRDR) & LDDRDR_DRD_MASK; in lcdc_sys_read_data()
450 struct sh_mobile_lcdc_chan *ch = info->par; in sh_mobile_lcdc_sginit() local
451 unsigned int nr_pages_max = ch->fb_size >> PAGE_SHIFT; in sh_mobile_lcdc_sginit()
455 sg_init_table(ch->sglist, nr_pages_max); in sh_mobile_lcdc_sginit()
458 sg_set_page(&ch->sglist[nr_pages++], page, PAGE_SIZE, 0); in sh_mobile_lcdc_sginit()
466 struct sh_mobile_lcdc_chan *ch = info->par; in sh_mobile_lcdc_deferred_io() local
467 const struct sh_mobile_lcdc_panel_cfg *panel = &ch->cfg->panel_cfg; in sh_mobile_lcdc_deferred_io()
470 sh_mobile_lcdc_clk_on(ch->lcdc); in sh_mobile_lcdc_deferred_io()
491 dma_map_sg(ch->lcdc->dev, ch->sglist, nr_pages, DMA_TO_DEVICE); in sh_mobile_lcdc_deferred_io()
493 panel->start_transfer(ch, &sh_mobile_lcdc_sys_bus_ops); in sh_mobile_lcdc_deferred_io()
494 lcdc_write_chan(ch, LDSM2R, LDSM2R_OSTRG); in sh_mobile_lcdc_deferred_io()
495 dma_unmap_sg(ch->lcdc->dev, ch->sglist, nr_pages, in sh_mobile_lcdc_deferred_io()
499 panel->start_transfer(ch, &sh_mobile_lcdc_sys_bus_ops); in sh_mobile_lcdc_deferred_io()
500 lcdc_write_chan(ch, LDSM2R, LDSM2R_OSTRG); in sh_mobile_lcdc_deferred_io()
512 static void sh_mobile_lcdc_display_on(struct sh_mobile_lcdc_chan *ch) in sh_mobile_lcdc_display_on() argument
514 const struct sh_mobile_lcdc_panel_cfg *panel = &ch->cfg->panel_cfg; in sh_mobile_lcdc_display_on()
516 if (ch->tx_dev) { in sh_mobile_lcdc_display_on()
519 ret = ch->tx_dev->ops->display_on(ch->tx_dev); in sh_mobile_lcdc_display_on()
524 ch->info->state = FBINFO_STATE_SUSPENDED; in sh_mobile_lcdc_display_on()
532 static void sh_mobile_lcdc_display_off(struct sh_mobile_lcdc_chan *ch) in sh_mobile_lcdc_display_off() argument
534 const struct sh_mobile_lcdc_panel_cfg *panel = &ch->cfg->panel_cfg; in sh_mobile_lcdc_display_off()
539 if (ch->tx_dev) in sh_mobile_lcdc_display_off()
540 ch->tx_dev->ops->display_off(ch->tx_dev); in sh_mobile_lcdc_display_off()
544 sh_mobile_lcdc_must_reconfigure(struct sh_mobile_lcdc_chan *ch, in sh_mobile_lcdc_must_reconfigure() argument
547 dev_dbg(ch->info->dev, "Old %ux%u, new %ux%u\n", in sh_mobile_lcdc_must_reconfigure()
548 ch->display.mode.xres, ch->display.mode.yres, in sh_mobile_lcdc_must_reconfigure()
552 if (fb_mode_is_equal(&ch->display.mode, new_mode)) in sh_mobile_lcdc_must_reconfigure()
555 dev_dbg(ch->info->dev, "Switching %u -> %u lines\n", in sh_mobile_lcdc_must_reconfigure()
556 ch->display.mode.yres, new_mode->yres); in sh_mobile_lcdc_must_reconfigure()
557 ch->display.mode = *new_mode; in sh_mobile_lcdc_must_reconfigure()
565 static int sh_mobile_lcdc_display_notify(struct sh_mobile_lcdc_chan *ch, in sh_mobile_lcdc_display_notify() argument
570 struct fb_info *info = ch->info; in sh_mobile_lcdc_display_notify()
581 ch->display.width = monspec->max_x * 10; in sh_mobile_lcdc_display_notify()
582 ch->display.height = monspec->max_y * 10; in sh_mobile_lcdc_display_notify()
584 if (!sh_mobile_lcdc_must_reconfigure(ch, mode) && in sh_mobile_lcdc_display_notify()
590 info->var.width = ch->display.width; in sh_mobile_lcdc_display_notify()
591 info->var.height = ch->display.height; in sh_mobile_lcdc_display_notify()
592 sh_mobile_lcdc_display_on(ch); in sh_mobile_lcdc_display_notify()
728 struct sh_mobile_lcdc_chan *ch; in sh_mobile_lcdc_irq() local
741 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { in sh_mobile_lcdc_irq()
742 ch = &priv->ch[k]; in sh_mobile_lcdc_irq()
744 if (!ch->enabled) in sh_mobile_lcdc_irq()
749 if (is_sub == lcdc_chan_is_sublcd(ch)) { in sh_mobile_lcdc_irq()
750 ch->frame_end = 1; in sh_mobile_lcdc_irq()
751 wake_up(&ch->frame_end_wait); in sh_mobile_lcdc_irq()
759 complete(&ch->vsync_completion); in sh_mobile_lcdc_irq()
765 static int sh_mobile_lcdc_wait_for_vsync(struct sh_mobile_lcdc_chan *ch) in sh_mobile_lcdc_wait_for_vsync() argument
773 ldintr = lcdc_read(ch->lcdc, _LDINTR); in sh_mobile_lcdc_wait_for_vsync()
775 lcdc_write(ch->lcdc, _LDINTR, ldintr); in sh_mobile_lcdc_wait_for_vsync()
777 ret = wait_for_completion_interruptible_timeout(&ch->vsync_completion, in sh_mobile_lcdc_wait_for_vsync()
798 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) in sh_mobile_lcdc_start_stop()
799 if (lcdc_read(priv, _LDCNT2R) & priv->ch[k].enabled) in sh_mobile_lcdc_start_stop()
801 tmp = lcdc_read_chan(&priv->ch[k], LDPMR) in sh_mobile_lcdc_start_stop()
814 static void sh_mobile_lcdc_geometry(struct sh_mobile_lcdc_chan *ch) in sh_mobile_lcdc_geometry() argument
816 const struct fb_var_screeninfo *var = &ch->info->var; in sh_mobile_lcdc_geometry()
817 const struct fb_videomode *mode = &ch->display.mode; in sh_mobile_lcdc_geometry()
821 tmp = ch->ldmt1r_value; in sh_mobile_lcdc_geometry()
824 tmp |= (ch->cfg->flags & LCDC_FLAGS_DWPOL) ? LDMT1R_DWPOL : 0; in sh_mobile_lcdc_geometry()
825 tmp |= (ch->cfg->flags & LCDC_FLAGS_DIPOL) ? LDMT1R_DIPOL : 0; in sh_mobile_lcdc_geometry()
826 tmp |= (ch->cfg->flags & LCDC_FLAGS_DAPOL) ? LDMT1R_DAPOL : 0; in sh_mobile_lcdc_geometry()
827 tmp |= (ch->cfg->flags & LCDC_FLAGS_HSCNT) ? LDMT1R_HSCNT : 0; in sh_mobile_lcdc_geometry()
828 tmp |= (ch->cfg->flags & LCDC_FLAGS_DWCNT) ? LDMT1R_DWCNT : 0; in sh_mobile_lcdc_geometry()
829 lcdc_write_chan(ch, LDMT1R, tmp); in sh_mobile_lcdc_geometry()
832 lcdc_write_chan(ch, LDMT2R, ch->cfg->sys_bus_cfg.ldmt2r); in sh_mobile_lcdc_geometry()
833 lcdc_write_chan(ch, LDMT3R, ch->cfg->sys_bus_cfg.ldmt3r); in sh_mobile_lcdc_geometry()
839 tmp |= (min(mode->xres, ch->xres) / 8) << 16; /* HDCN */ in sh_mobile_lcdc_geometry()
840 lcdc_write_chan(ch, LDHCNR, tmp); in sh_mobile_lcdc_geometry()
845 lcdc_write_chan(ch, LDHSYNR, tmp); in sh_mobile_lcdc_geometry()
850 tmp |= min(mode->yres, ch->yres) << 16; /* VDLN */ in sh_mobile_lcdc_geometry()
851 lcdc_write_chan(ch, LDVLNR, tmp); in sh_mobile_lcdc_geometry()
855 lcdc_write_chan(ch, LDVSYNR, tmp); in sh_mobile_lcdc_geometry()
862 lcdc_write_chan(ch, LDHAJR, tmp); in sh_mobile_lcdc_geometry()
863 lcdc_write_chan_mirror(ch, LDHAJR, tmp); in sh_mobile_lcdc_geometry()
965 struct sh_mobile_lcdc_chan *ch; in __sh_mobile_lcdc_start() local
972 lcdc_write(priv, _LDCNT2R, priv->ch[0].enabled | priv->ch[1].enabled); in __sh_mobile_lcdc_start()
980 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { in __sh_mobile_lcdc_start()
981 ch = &priv->ch[k]; in __sh_mobile_lcdc_start()
982 if (!ch->enabled) in __sh_mobile_lcdc_start()
986 lcdc_write_chan(ch, LDPMR, 0); in __sh_mobile_lcdc_start()
988 m = ch->cfg->clock_divider; in __sh_mobile_lcdc_start()
995 lcdc_write_chan(ch, LDDCKPAT1R, 0); in __sh_mobile_lcdc_start()
996 lcdc_write_chan(ch, LDDCKPAT2R, (1 << (m/2)) - 1); in __sh_mobile_lcdc_start()
1000 tmp |= m << (lcdc_chan_is_sublcd(ch) ? 8 : 0); in __sh_mobile_lcdc_start()
1008 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { in __sh_mobile_lcdc_start()
1009 ch = &priv->ch[k]; in __sh_mobile_lcdc_start()
1010 if (!ch->enabled) in __sh_mobile_lcdc_start()
1013 sh_mobile_lcdc_geometry(ch); in __sh_mobile_lcdc_start()
1015 tmp = ch->format->lddfr; in __sh_mobile_lcdc_start()
1017 if (ch->format->yuv) { in __sh_mobile_lcdc_start()
1018 switch (ch->colorspace) { in __sh_mobile_lcdc_start()
1028 lcdc_write_chan(ch, LDDFR, tmp); in __sh_mobile_lcdc_start()
1029 lcdc_write_chan(ch, LDMLSR, ch->line_size); in __sh_mobile_lcdc_start()
1030 lcdc_write_chan(ch, LDSA1R, ch->base_addr_y); in __sh_mobile_lcdc_start()
1031 if (ch->format->yuv) in __sh_mobile_lcdc_start()
1032 lcdc_write_chan(ch, LDSA2R, ch->base_addr_c); in __sh_mobile_lcdc_start()
1038 if (ch->ldmt1r_value & LDMT1R_IFM && in __sh_mobile_lcdc_start()
1039 ch->cfg->sys_bus_cfg.deferred_io_msec) { in __sh_mobile_lcdc_start()
1040 lcdc_write_chan(ch, LDSM1R, LDSM1R_OS); in __sh_mobile_lcdc_start()
1043 lcdc_write_chan(ch, LDSM1R, 0); in __sh_mobile_lcdc_start()
1048 switch (priv->ch[0].format->fourcc) { in __sh_mobile_lcdc_start()
1077 struct sh_mobile_lcdc_chan *ch; in sh_mobile_lcdc_start() local
1083 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { in sh_mobile_lcdc_start()
1084 if (priv->ch[k].enabled) in sh_mobile_lcdc_start()
1092 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { in sh_mobile_lcdc_start()
1095 ch = &priv->ch[k]; in sh_mobile_lcdc_start()
1096 if (!ch->enabled) in sh_mobile_lcdc_start()
1099 panel = &ch->cfg->panel_cfg; in sh_mobile_lcdc_start()
1101 ret = panel->setup_sys(ch, &sh_mobile_lcdc_sys_bus_ops); in sh_mobile_lcdc_start()
1108 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { in sh_mobile_lcdc_start()
1112 ch = &priv->ch[k]; in sh_mobile_lcdc_start()
1113 if (!ch->enabled) in sh_mobile_lcdc_start()
1116 ch->base_addr_y = ch->dma_handle; in sh_mobile_lcdc_start()
1117 ch->base_addr_c = ch->dma_handle in sh_mobile_lcdc_start()
1118 + ch->xres_virtual * ch->yres_virtual; in sh_mobile_lcdc_start()
1119 ch->line_size = ch->pitch; in sh_mobile_lcdc_start()
1122 if (mdev == NULL || ch->cfg->meram_cfg == NULL) in sh_mobile_lcdc_start()
1126 if (ch->cache) { in sh_mobile_lcdc_start()
1127 sh_mobile_meram_cache_free(mdev, ch->cache); in sh_mobile_lcdc_start()
1128 ch->cache = NULL; in sh_mobile_lcdc_start()
1131 switch (ch->format->fourcc) { in sh_mobile_lcdc_start()
1150 cache = sh_mobile_meram_cache_alloc(mdev, ch->cfg->meram_cfg, in sh_mobile_lcdc_start()
1151 ch->pitch, ch->yres, pixelformat, in sh_mobile_lcdc_start()
1152 &ch->line_size); in sh_mobile_lcdc_start()
1155 ch->base_addr_y, ch->base_addr_c, in sh_mobile_lcdc_start()
1156 &ch->base_addr_y, &ch->base_addr_c); in sh_mobile_lcdc_start()
1157 ch->cache = cache; in sh_mobile_lcdc_start()
1172 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { in sh_mobile_lcdc_start()
1173 ch = &priv->ch[k]; in sh_mobile_lcdc_start()
1174 if (!ch->enabled) in sh_mobile_lcdc_start()
1177 tmp = ch->cfg->sys_bus_cfg.deferred_io_msec; in sh_mobile_lcdc_start()
1178 if (ch->ldmt1r_value & LDMT1R_IFM && tmp) { in sh_mobile_lcdc_start()
1179 ch->defio.deferred_io = sh_mobile_lcdc_deferred_io; in sh_mobile_lcdc_start()
1180 ch->defio.delay = msecs_to_jiffies(tmp); in sh_mobile_lcdc_start()
1181 ch->info->fbdefio = &ch->defio; in sh_mobile_lcdc_start()
1182 fb_deferred_io_init(ch->info); in sh_mobile_lcdc_start()
1185 sh_mobile_lcdc_display_on(ch); in sh_mobile_lcdc_start()
1187 if (ch->bl) { in sh_mobile_lcdc_start()
1188 ch->bl->props.power = FB_BLANK_UNBLANK; in sh_mobile_lcdc_start()
1189 backlight_update_status(ch->bl); in sh_mobile_lcdc_start()
1198 struct sh_mobile_lcdc_chan *ch; in sh_mobile_lcdc_stop() local
1202 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { in sh_mobile_lcdc_stop()
1203 ch = &priv->ch[k]; in sh_mobile_lcdc_stop()
1204 if (!ch->enabled) in sh_mobile_lcdc_stop()
1211 if (ch->info && ch->info->fbdefio) { in sh_mobile_lcdc_stop()
1212 ch->frame_end = 0; in sh_mobile_lcdc_stop()
1213 schedule_delayed_work(&ch->info->deferred_work, 0); in sh_mobile_lcdc_stop()
1214 wait_event(ch->frame_end_wait, ch->frame_end); in sh_mobile_lcdc_stop()
1215 fb_deferred_io_cleanup(ch->info); in sh_mobile_lcdc_stop()
1216 ch->info->fbdefio = NULL; in sh_mobile_lcdc_stop()
1220 if (ch->bl) { in sh_mobile_lcdc_stop()
1221 ch->bl->props.power = FB_BLANK_POWERDOWN; in sh_mobile_lcdc_stop()
1222 backlight_update_status(ch->bl); in sh_mobile_lcdc_stop()
1225 sh_mobile_lcdc_display_off(ch); in sh_mobile_lcdc_stop()
1228 if (ch->cache) { in sh_mobile_lcdc_stop()
1229 sh_mobile_meram_cache_free(priv->meram_dev, ch->cache); in sh_mobile_lcdc_stop()
1230 ch->cache = NULL; in sh_mobile_lcdc_stop()
1242 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) in sh_mobile_lcdc_stop()
1243 if (priv->ch[k].enabled) in sh_mobile_lcdc_stop()
1823 struct sh_mobile_lcdc_chan *ch = info->par; in sh_mobile_lcdc_pan() local
1824 struct sh_mobile_lcdc_priv *priv = ch->lcdc; in sh_mobile_lcdc_pan()
1830 if (!ch->format->yuv) { in sh_mobile_lcdc_pan()
1831 y_offset = (var->yoffset * ch->xres_virtual + var->xoffset) in sh_mobile_lcdc_pan()
1832 * ch->format->bpp / 8; in sh_mobile_lcdc_pan()
1835 unsigned int xsub = ch->format->bpp < 24 ? 2 : 1; in sh_mobile_lcdc_pan()
1836 unsigned int ysub = ch->format->bpp < 16 ? 2 : 1; in sh_mobile_lcdc_pan()
1838 y_offset = var->yoffset * ch->xres_virtual + var->xoffset; in sh_mobile_lcdc_pan()
1839 c_offset = var->yoffset / ysub * ch->xres_virtual * 2 / xsub in sh_mobile_lcdc_pan()
1846 if (y_offset == ch->pan_y_offset) in sh_mobile_lcdc_pan()
1850 base_addr_y = ch->dma_handle + y_offset; in sh_mobile_lcdc_pan()
1851 base_addr_c = ch->dma_handle + ch->xres_virtual * ch->yres_virtual in sh_mobile_lcdc_pan()
1854 if (ch->cache) in sh_mobile_lcdc_pan()
1855 sh_mobile_meram_cache_update(priv->meram_dev, ch->cache, in sh_mobile_lcdc_pan()
1859 ch->base_addr_y = base_addr_y; in sh_mobile_lcdc_pan()
1860 ch->base_addr_c = base_addr_c; in sh_mobile_lcdc_pan()
1861 ch->pan_y_offset = y_offset; in sh_mobile_lcdc_pan()
1863 lcdc_write_chan_mirror(ch, LDSA1R, base_addr_y); in sh_mobile_lcdc_pan()
1864 if (ch->format->yuv) in sh_mobile_lcdc_pan()
1865 lcdc_write_chan_mirror(ch, LDSA2R, base_addr_c); in sh_mobile_lcdc_pan()
1868 if (lcdc_chan_is_sublcd(ch)) in sh_mobile_lcdc_pan()
1869 lcdc_write(ch->lcdc, _LDRCNTR, ldrcntr ^ LDRCNTR_SRS); in sh_mobile_lcdc_pan()
1871 lcdc_write(ch->lcdc, _LDRCNTR, ldrcntr ^ LDRCNTR_MRS); in sh_mobile_lcdc_pan()
1882 struct sh_mobile_lcdc_chan *ch = info->par; in sh_mobile_lcdc_ioctl() local
1887 retval = sh_mobile_lcdc_wait_for_vsync(ch); in sh_mobile_lcdc_ioctl()
1899 struct sh_mobile_lcdc_chan *ch = info->par; in sh_mobile_fb_reconfig() local
1905 if (ch->use_count > 1 || (ch->use_count == 1 && !info->fbcon_par)) in sh_mobile_fb_reconfig()
1911 if (fb_mode_is_equal(&ch->display.mode, &mode)) in sh_mobile_fb_reconfig()
1916 fb_videomode_to_var(&var, &ch->display.mode); in sh_mobile_fb_reconfig()
1917 var.width = ch->display.width; in sh_mobile_fb_reconfig()
1918 var.height = ch->display.height; in sh_mobile_fb_reconfig()
1931 event.data = &ch->display.mode; in sh_mobile_fb_reconfig()
1941 struct sh_mobile_lcdc_chan *ch = info->par; in sh_mobile_lcdc_release() local
1943 mutex_lock(&ch->open_lock); in sh_mobile_lcdc_release()
1944 dev_dbg(info->dev, "%s(): %d users\n", __func__, ch->use_count); in sh_mobile_lcdc_release()
1946 ch->use_count--; in sh_mobile_lcdc_release()
1955 mutex_unlock(&ch->open_lock); in sh_mobile_lcdc_release()
1962 struct sh_mobile_lcdc_chan *ch = info->par; in sh_mobile_lcdc_open() local
1964 mutex_lock(&ch->open_lock); in sh_mobile_lcdc_open()
1965 ch->use_count++; in sh_mobile_lcdc_open()
1967 dev_dbg(info->dev, "%s(): %d users\n", __func__, ch->use_count); in sh_mobile_lcdc_open()
1968 mutex_unlock(&ch->open_lock); in sh_mobile_lcdc_open()
1976 struct sh_mobile_lcdc_chan *ch = info->par; in sh_mobile_lcdc_check_var() local
1977 struct sh_mobile_lcdc_priv *p = ch->lcdc; in sh_mobile_lcdc_check_var()
1989 for (i = 0; i < ch->cfg->num_modes; ++i) { in sh_mobile_lcdc_check_var()
1990 const struct fb_videomode *mode = &ch->cfg->lcd_modes[i]; in sh_mobile_lcdc_check_var()
2009 if (ch->cfg->num_modes != 0) { in sh_mobile_lcdc_check_var()
2031 struct sh_mobile_lcdc_chan *ch = info->par; in sh_mobile_lcdc_set_par() local
2034 sh_mobile_lcdc_stop(ch->lcdc); in sh_mobile_lcdc_set_par()
2036 ch->format = sh_mobile_format_info(sh_mobile_format_fourcc(&info->var)); in sh_mobile_lcdc_set_par()
2037 ch->colorspace = info->var.colorspace; in sh_mobile_lcdc_set_par()
2039 ch->xres = info->var.xres; in sh_mobile_lcdc_set_par()
2040 ch->xres_virtual = info->var.xres_virtual; in sh_mobile_lcdc_set_par()
2041 ch->yres = info->var.yres; in sh_mobile_lcdc_set_par()
2042 ch->yres_virtual = info->var.yres_virtual; in sh_mobile_lcdc_set_par()
2044 if (ch->format->yuv) in sh_mobile_lcdc_set_par()
2045 ch->pitch = info->var.xres_virtual; in sh_mobile_lcdc_set_par()
2047 ch->pitch = info->var.xres_virtual * ch->format->bpp / 8; in sh_mobile_lcdc_set_par()
2049 ret = sh_mobile_lcdc_start(ch->lcdc); in sh_mobile_lcdc_set_par()
2053 info->fix.line_length = ch->pitch; in sh_mobile_lcdc_set_par()
2076 struct sh_mobile_lcdc_chan *ch = info->par; in sh_mobile_lcdc_blank() local
2077 struct sh_mobile_lcdc_priv *p = ch->lcdc; in sh_mobile_lcdc_blank()
2080 if (blank > FB_BLANK_UNBLANK && ch->blank_status == FB_BLANK_UNBLANK) { in sh_mobile_lcdc_blank()
2082 .width = ch->xres, in sh_mobile_lcdc_blank()
2083 .height = ch->yres, in sh_mobile_lcdc_blank()
2088 if (blank <= FB_BLANK_NORMAL && ch->blank_status > FB_BLANK_NORMAL) { in sh_mobile_lcdc_blank()
2092 if (blank > FB_BLANK_NORMAL && ch->blank_status <= FB_BLANK_NORMAL) { in sh_mobile_lcdc_blank()
2099 sh_mobile_lcdc_wait_for_vsync(ch); in sh_mobile_lcdc_blank()
2100 sh_mobile_lcdc_wait_for_vsync(ch); in sh_mobile_lcdc_blank()
2105 ch->blank_status = blank; in sh_mobile_lcdc_blank()
2112 struct sh_mobile_lcdc_chan *ch = info->par; in sh_mobile_lcdc_mmap() local
2114 return dma_mmap_coherent(ch->lcdc->dev, vma, ch->fb_mem, in sh_mobile_lcdc_mmap()
2115 ch->dma_handle, ch->fb_size); in sh_mobile_lcdc_mmap()
2137 sh_mobile_lcdc_channel_fb_unregister(struct sh_mobile_lcdc_chan *ch) in sh_mobile_lcdc_channel_fb_unregister() argument
2139 if (ch->info && ch->info->dev) in sh_mobile_lcdc_channel_fb_unregister()
2140 unregister_framebuffer(ch->info); in sh_mobile_lcdc_channel_fb_unregister()
2144 sh_mobile_lcdc_channel_fb_register(struct sh_mobile_lcdc_chan *ch) in sh_mobile_lcdc_channel_fb_register() argument
2146 struct fb_info *info = ch->info; in sh_mobile_lcdc_channel_fb_register()
2150 ch->sglist = vmalloc(sizeof(struct scatterlist) * in sh_mobile_lcdc_channel_fb_register()
2151 ch->fb_size >> PAGE_SHIFT); in sh_mobile_lcdc_channel_fb_register()
2152 if (!ch->sglist) { in sh_mobile_lcdc_channel_fb_register()
2153 dev_err(ch->lcdc->dev, "cannot allocate sglist\n"); in sh_mobile_lcdc_channel_fb_register()
2158 info->bl_dev = ch->bl; in sh_mobile_lcdc_channel_fb_register()
2164 dev_info(ch->lcdc->dev, "registered %s/%s as %dx%d %dbpp.\n", in sh_mobile_lcdc_channel_fb_register()
2165 dev_name(ch->lcdc->dev), (ch->cfg->chan == LCDC_CHAN_MAINLCD) ? in sh_mobile_lcdc_channel_fb_register()
2171 sh_mobile_lcdc_clk_off(ch->lcdc); in sh_mobile_lcdc_channel_fb_register()
2177 sh_mobile_lcdc_channel_fb_cleanup(struct sh_mobile_lcdc_chan *ch) in sh_mobile_lcdc_channel_fb_cleanup() argument
2179 struct fb_info *info = ch->info; in sh_mobile_lcdc_channel_fb_cleanup()
2184 vfree(ch->sglist); in sh_mobile_lcdc_channel_fb_cleanup()
2191 sh_mobile_lcdc_channel_fb_init(struct sh_mobile_lcdc_chan *ch, in sh_mobile_lcdc_channel_fb_init() argument
2195 struct sh_mobile_lcdc_priv *priv = ch->lcdc; in sh_mobile_lcdc_channel_fb_init()
2209 ch->info = info; in sh_mobile_lcdc_channel_fb_init()
2214 info->screen_base = ch->fb_mem; in sh_mobile_lcdc_channel_fb_init()
2215 info->pseudo_palette = &ch->pseudo_palette; in sh_mobile_lcdc_channel_fb_init()
2216 info->par = ch; in sh_mobile_lcdc_channel_fb_init()
2230 info->fix.smem_start = ch->dma_handle; in sh_mobile_lcdc_channel_fb_init()
2231 info->fix.smem_len = ch->fb_size; in sh_mobile_lcdc_channel_fb_init()
2232 info->fix.line_length = ch->pitch; in sh_mobile_lcdc_channel_fb_init()
2234 if (ch->format->yuv) in sh_mobile_lcdc_channel_fb_init()
2239 switch (ch->format->fourcc) { in sh_mobile_lcdc_channel_fb_init()
2253 var->width = ch->display.width; in sh_mobile_lcdc_channel_fb_init()
2254 var->height = ch->display.height; in sh_mobile_lcdc_channel_fb_init()
2255 var->xres_virtual = ch->xres_virtual; in sh_mobile_lcdc_channel_fb_init()
2256 var->yres_virtual = ch->yres_virtual; in sh_mobile_lcdc_channel_fb_init()
2262 if (!ch->format->yuv) in sh_mobile_lcdc_channel_fb_init()
2263 var->bits_per_pixel = ch->format->bpp; in sh_mobile_lcdc_channel_fb_init()
2265 var->grayscale = ch->format->fourcc; in sh_mobile_lcdc_channel_fb_init()
2280 struct sh_mobile_lcdc_chan *ch = bl_get_data(bdev); in sh_mobile_lcdc_update_bl() local
2287 ch->bl_brightness = brightness; in sh_mobile_lcdc_update_bl()
2288 return ch->cfg->bl_info.set_brightness(brightness); in sh_mobile_lcdc_update_bl()
2293 struct sh_mobile_lcdc_chan *ch = bl_get_data(bdev); in sh_mobile_lcdc_get_brightness() local
2295 return ch->bl_brightness; in sh_mobile_lcdc_get_brightness()
2312 struct sh_mobile_lcdc_chan *ch) in sh_mobile_lcdc_bl_probe() argument
2316 bl = backlight_device_register(ch->cfg->bl_info.name, parent, ch, in sh_mobile_lcdc_bl_probe()
2324 bl->props.max_brightness = ch->cfg->bl_info.max_brightness; in sh_mobile_lcdc_bl_probe()
2393 struct sh_mobile_lcdc_chan *ch = info->par; in sh_mobile_lcdc_notify() local
2395 if (&ch->lcdc->notifier != nb) in sh_mobile_lcdc_notify()
2403 sh_mobile_lcdc_display_off(ch); in sh_mobile_lcdc_notify()
2404 sh_mobile_lcdc_stop(ch->lcdc); in sh_mobile_lcdc_notify()
2407 mutex_lock(&ch->open_lock); in sh_mobile_lcdc_notify()
2409 mutex_unlock(&ch->open_lock); in sh_mobile_lcdc_notify()
2411 sh_mobile_lcdc_display_on(ch); in sh_mobile_lcdc_notify()
2412 sh_mobile_lcdc_start(ch->lcdc); in sh_mobile_lcdc_notify()
2449 for (i = 0; i < ARRAY_SIZE(priv->ch); i++) in sh_mobile_lcdc_remove()
2450 sh_mobile_lcdc_channel_fb_unregister(&priv->ch[i]); in sh_mobile_lcdc_remove()
2464 for (i = 0; i < ARRAY_SIZE(priv->ch); i++) { in sh_mobile_lcdc_remove()
2465 struct sh_mobile_lcdc_chan *ch = &priv->ch[i]; in sh_mobile_lcdc_remove() local
2467 if (ch->tx_dev) { in sh_mobile_lcdc_remove()
2468 ch->tx_dev->lcdc = NULL; in sh_mobile_lcdc_remove()
2469 module_put(ch->cfg->tx_dev->dev.driver->owner); in sh_mobile_lcdc_remove()
2472 sh_mobile_lcdc_channel_fb_cleanup(ch); in sh_mobile_lcdc_remove()
2474 if (ch->fb_mem) in sh_mobile_lcdc_remove()
2475 dma_free_coherent(&pdev->dev, ch->fb_size, in sh_mobile_lcdc_remove()
2476 ch->fb_mem, ch->dma_handle); in sh_mobile_lcdc_remove()
2479 for (i = 0; i < ARRAY_SIZE(priv->ch); i++) { in sh_mobile_lcdc_remove()
2480 struct sh_mobile_lcdc_chan *ch = &priv->ch[i]; in sh_mobile_lcdc_remove() local
2482 if (ch->bl) in sh_mobile_lcdc_remove()
2483 sh_mobile_lcdc_bl_remove(ch->bl); in sh_mobile_lcdc_remove()
2484 mutex_destroy(&ch->open_lock); in sh_mobile_lcdc_remove()
2501 static int sh_mobile_lcdc_check_interface(struct sh_mobile_lcdc_chan *ch) in sh_mobile_lcdc_check_interface() argument
2503 int interface_type = ch->cfg->interface_type; in sh_mobile_lcdc_check_interface()
2530 if (lcdc_chan_is_sublcd(ch)) { in sh_mobile_lcdc_check_interface()
2537 ch->ldmt1r_value = interface_type; in sh_mobile_lcdc_check_interface()
2597 sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch) in sh_mobile_lcdc_channel_init() argument
2600 const struct sh_mobile_lcdc_chan_cfg *cfg = ch->cfg; in sh_mobile_lcdc_channel_init()
2601 struct device *dev = ch->lcdc->dev; in sh_mobile_lcdc_channel_init()
2608 ch->notify = sh_mobile_lcdc_display_notify; in sh_mobile_lcdc_channel_init()
2657 ch->format = format; in sh_mobile_lcdc_channel_init()
2658 ch->xres = mode->xres; in sh_mobile_lcdc_channel_init()
2659 ch->xres_virtual = mode->xres; in sh_mobile_lcdc_channel_init()
2660 ch->yres = mode->yres; in sh_mobile_lcdc_channel_init()
2661 ch->yres_virtual = mode->yres * 2; in sh_mobile_lcdc_channel_init()
2664 ch->colorspace = V4L2_COLORSPACE_SRGB; in sh_mobile_lcdc_channel_init()
2665 ch->pitch = ch->xres_virtual * format->bpp / 8; in sh_mobile_lcdc_channel_init()
2667 ch->colorspace = V4L2_COLORSPACE_REC709; in sh_mobile_lcdc_channel_init()
2668 ch->pitch = ch->xres_virtual; in sh_mobile_lcdc_channel_init()
2671 ch->display.width = cfg->panel_cfg.width; in sh_mobile_lcdc_channel_init()
2672 ch->display.height = cfg->panel_cfg.height; in sh_mobile_lcdc_channel_init()
2673 ch->display.mode = *mode; in sh_mobile_lcdc_channel_init()
2676 ch->fb_size = max_size * format->bpp / 8 * 2; in sh_mobile_lcdc_channel_init()
2677 ch->fb_mem = dma_alloc_coherent(dev, ch->fb_size, &ch->dma_handle, in sh_mobile_lcdc_channel_init()
2679 if (ch->fb_mem == NULL) { in sh_mobile_lcdc_channel_init()
2691 ch->tx_dev = platform_get_drvdata(cfg->tx_dev); in sh_mobile_lcdc_channel_init()
2692 ch->tx_dev->lcdc = ch; in sh_mobile_lcdc_channel_init()
2693 ch->tx_dev->def_mode = *mode; in sh_mobile_lcdc_channel_init()
2696 return sh_mobile_lcdc_channel_fb_init(ch, mode, num_modes); in sh_mobile_lcdc_channel_init()
2728 for (i = 0; i < ARRAY_SIZE(priv->ch); i++) in sh_mobile_lcdc_probe()
2729 mutex_init(&priv->ch[i].open_lock); in sh_mobile_lcdc_probe()
2742 for (i = 0, num_channels = 0; i < ARRAY_SIZE(pdata->ch); i++) { in sh_mobile_lcdc_probe()
2743 struct sh_mobile_lcdc_chan *ch = priv->ch + num_channels; in sh_mobile_lcdc_probe() local
2745 ch->lcdc = priv; in sh_mobile_lcdc_probe()
2746 ch->cfg = &pdata->ch[i]; in sh_mobile_lcdc_probe()
2748 error = sh_mobile_lcdc_check_interface(ch); in sh_mobile_lcdc_probe()
2753 init_waitqueue_head(&ch->frame_end_wait); in sh_mobile_lcdc_probe()
2754 init_completion(&ch->vsync_completion); in sh_mobile_lcdc_probe()
2757 if (ch->cfg->bl_info.max_brightness) in sh_mobile_lcdc_probe()
2758 ch->bl = sh_mobile_lcdc_bl_probe(&pdev->dev, ch); in sh_mobile_lcdc_probe()
2760 switch (pdata->ch[i].chan) { in sh_mobile_lcdc_probe()
2762 ch->enabled = LDCNT2R_ME; in sh_mobile_lcdc_probe()
2763 ch->reg_offs = lcdc_offs_mainlcd; in sh_mobile_lcdc_probe()
2767 ch->enabled = LDCNT2R_SE; in sh_mobile_lcdc_probe()
2768 ch->reg_offs = lcdc_offs_sublcd; in sh_mobile_lcdc_probe()
2782 priv->forced_fourcc = pdata->ch[0].fourcc; in sh_mobile_lcdc_probe()
2798 struct sh_mobile_lcdc_chan *ch = &priv->ch[i]; in sh_mobile_lcdc_probe() local
2800 error = sh_mobile_lcdc_channel_init(ch); in sh_mobile_lcdc_probe()
2809 ovl->channel = &priv->ch[0]; in sh_mobile_lcdc_probe()
2823 struct sh_mobile_lcdc_chan *ch = priv->ch + i; in sh_mobile_lcdc_probe() local
2825 error = sh_mobile_lcdc_channel_fb_register(ch); in sh_mobile_lcdc_probe()