15 #include <linux/ctype.h>
22 #include <linux/kernel.h>
24 #include <linux/module.h>
27 #include <linux/slab.h>
28 #include <linux/videodev2.h>
41 #define LDBCR_UPC(n) (1 << ((n) + 16))
42 #define LDBCR_UPF(n) (1 << ((n) + 8))
43 #define LDBCR_UPD(n) (1 << ((n) + 0))
44 #define LDBnBSIFR(n) (0xb20 + (n) * 0x20 + 0x00)
45 #define LDBBSIFR_EN (1 << 31)
46 #define LDBBSIFR_VS (1 << 29)
47 #define LDBBSIFR_BRSEL (1 << 28)
48 #define LDBBSIFR_MX (1 << 27)
49 #define LDBBSIFR_MY (1 << 26)
50 #define LDBBSIFR_CV3 (3 << 24)
51 #define LDBBSIFR_CV2 (2 << 24)
52 #define LDBBSIFR_CV1 (1 << 24)
53 #define LDBBSIFR_CV0 (0 << 24)
54 #define LDBBSIFR_CV_MASK (3 << 24)
55 #define LDBBSIFR_LAY_MASK (0xff << 16)
56 #define LDBBSIFR_LAY_SHIFT 16
57 #define LDBBSIFR_ROP3_MASK (0xff << 16)
58 #define LDBBSIFR_ROP3_SHIFT 16
59 #define LDBBSIFR_AL_PL8 (3 << 14)
60 #define LDBBSIFR_AL_PL1 (2 << 14)
61 #define LDBBSIFR_AL_PK (1 << 14)
62 #define LDBBSIFR_AL_1 (0 << 14)
63 #define LDBBSIFR_AL_MASK (3 << 14)
64 #define LDBBSIFR_SWPL (1 << 10)
65 #define LDBBSIFR_SWPW (1 << 9)
66 #define LDBBSIFR_SWPB (1 << 8)
67 #define LDBBSIFR_RY (1 << 7)
68 #define LDBBSIFR_CHRR_420 (2 << 0)
69 #define LDBBSIFR_CHRR_422 (1 << 0)
70 #define LDBBSIFR_CHRR_444 (0 << 0)
71 #define LDBBSIFR_RPKF_ARGB32 (0x00 << 0)
72 #define LDBBSIFR_RPKF_RGB16 (0x03 << 0)
73 #define LDBBSIFR_RPKF_RGB24 (0x0b << 0)
74 #define LDBBSIFR_RPKF_MASK (0x1f << 0)
75 #define LDBnBSSZR(n) (0xb20 + (n) * 0x20 + 0x04)
76 #define LDBBSSZR_BVSS_MASK (0xfff << 16)
77 #define LDBBSSZR_BVSS_SHIFT 16
78 #define LDBBSSZR_BHSS_MASK (0xfff << 0)
79 #define LDBBSSZR_BHSS_SHIFT 0
80 #define LDBnBLOCR(n) (0xb20 + (n) * 0x20 + 0x08)
81 #define LDBBLOCR_CVLC_MASK (0xfff << 16)
82 #define LDBBLOCR_CVLC_SHIFT 16
83 #define LDBBLOCR_CHLC_MASK (0xfff << 0)
84 #define LDBBLOCR_CHLC_SHIFT 0
85 #define LDBnBSMWR(n) (0xb20 + (n) * 0x20 + 0x0c)
86 #define LDBBSMWR_BSMWA_MASK (0xffff << 16)
87 #define LDBBSMWR_BSMWA_SHIFT 16
88 #define LDBBSMWR_BSMW_MASK (0xffff << 0)
89 #define LDBBSMWR_BSMW_SHIFT 0
90 #define LDBnBSAYR(n) (0xb20 + (n) * 0x20 + 0x10)
91 #define LDBBSAYR_FG1A_MASK (0xff << 24)
92 #define LDBBSAYR_FG1A_SHIFT 24
93 #define LDBBSAYR_FG1R_MASK (0xff << 16)
94 #define LDBBSAYR_FG1R_SHIFT 16
95 #define LDBBSAYR_FG1G_MASK (0xff << 8)
96 #define LDBBSAYR_FG1G_SHIFT 8
97 #define LDBBSAYR_FG1B_MASK (0xff << 0)
98 #define LDBBSAYR_FG1B_SHIFT 0
99 #define LDBnBSACR(n) (0xb20 + (n) * 0x20 + 0x14)
100 #define LDBBSACR_FG2A_MASK (0xff << 24)
101 #define LDBBSACR_FG2A_SHIFT 24
102 #define LDBBSACR_FG2R_MASK (0xff << 16)
103 #define LDBBSACR_FG2R_SHIFT 16
104 #define LDBBSACR_FG2G_MASK (0xff << 8)
105 #define LDBBSACR_FG2G_SHIFT 8
106 #define LDBBSACR_FG2B_MASK (0xff << 0)
107 #define LDBBSACR_FG2B_SHIFT 0
108 #define LDBnBSAAR(n) (0xb20 + (n) * 0x20 + 0x18)
109 #define LDBBSAAR_AP_MASK (0xff << 24)
110 #define LDBBSAAR_AP_SHIFT 24
111 #define LDBBSAAR_R_MASK (0xff << 16)
112 #define LDBBSAAR_R_SHIFT 16
113 #define LDBBSAAR_GY_MASK (0xff << 8)
114 #define LDBBSAAR_GY_SHIFT 8
115 #define LDBBSAAR_B_MASK (0xff << 0)
116 #define LDBBSAAR_B_SHIFT 0
117 #define LDBnBPPCR(n) (0xb20 + (n) * 0x20 + 0x1c)
118 #define LDBBPPCR_AP_MASK (0xff << 24)
119 #define LDBBPPCR_AP_SHIFT 24
120 #define LDBBPPCR_R_MASK (0xff << 16)
121 #define LDBBPPCR_R_SHIFT 16
122 #define LDBBPPCR_GY_MASK (0xff << 8)
123 #define LDBBPPCR_GY_SHIFT 8
124 #define LDBBPPCR_B_MASK (0xff << 0)
125 #define LDBBPPCR_B_SHIFT 0
126 #define LDBnBBGCL(n) (0xb10 + (n) * 0x04)
127 #define LDBBBGCL_BGA_MASK (0xff << 24)
128 #define LDBBBGCL_BGA_SHIFT 24
129 #define LDBBBGCL_BGR_MASK (0xff << 16)
130 #define LDBBBGCL_BGR_SHIFT 16
131 #define LDBBBGCL_BGG_MASK (0xff << 8)
132 #define LDBBBGCL_BGG_SHIFT 8
133 #define LDBBBGCL_BGB_MASK (0xff << 0)
134 #define LDBBBGCL_BGB_SHIFT 0
136 #define SIDE_B_OFFSET 0x1000
137 #define MIRROR_OFFSET 0x2000
139 #define MAX_XRES 1920
140 #define MAX_YRES 1080
227 static unsigned long lcdc_offs_mainlcd[
NR_CH_REGS] = {
247 static unsigned long lcdc_offs_sublcd[
NR_CH_REGS] = {
265 static bool banked(
int reg_nr)
291 int reg_nr,
unsigned long data)
300 int reg_nr,
unsigned long data)
313 int reg,
unsigned long data)
320 unsigned long reg_offs,
unsigned long data)
326 unsigned long reg_offs)
332 unsigned long reg_offs,
333 unsigned long mask,
unsigned long until)
335 while ((lcdc_read(priv, reg_offs) & mask) != until)
348 pm_runtime_get_sync(priv->
dev);
350 pm_runtime_get_sync(&priv->
meram_dev->pdev->dev);
358 pm_runtime_put_sync(&priv->
meram_dev->pdev->dev);
359 pm_runtime_put(priv->
dev);
371 switch (clock_source) {
377 str =
"peripheral_clk";
393 dev_err(priv->
dev,
"cannot get dot clock %s\n", str);
405 static void lcdc_sys_write_index(
void *
handle,
unsigned long data)
412 (lcdc_chan_is_sublcd(ch) ? 2 : 0));
416 static void lcdc_sys_write_data(
void *handle,
unsigned long data)
423 (lcdc_chan_is_sublcd(ch) ? 2 : 0));
427 static unsigned long lcdc_sys_read_data(
void *handle)
434 (lcdc_chan_is_sublcd(ch) ? 2 : 0));
442 lcdc_sys_write_index,
447 static int sh_mobile_lcdc_sginit(
struct fb_info *
info,
458 sg_set_page(&ch->sglist[nr_pages++], page,
PAGE_SIZE, 0);
470 sh_mobile_lcdc_clk_on(ch->
lcdc);
487 if (!list_empty(pagelist)) {
488 unsigned int nr_pages = sh_mobile_lcdc_sginit(info, pagelist);
504 static void sh_mobile_lcdc_deferred_io_touch(
struct fb_info *info)
506 struct fb_deferred_io *fbdefio = info->fbdefio;
555 dev_dbg(ch->
info->dev,
"Switching %u -> %u lines\n",
583 if (!sh_mobile_lcdc_must_reconfigure(ch, mode) &&
589 info->
var.width = monspec->
max_x * 10;
590 info->
var.height = monspec->
max_y * 10;
591 sh_mobile_lcdc_display_on(ch);
598 unlock_fb_info(info);
608 unlock_fb_info(info);
615 var.bits_per_pixel = info->
var.bits_per_pixel;
616 var.grayscale = info->
var.grayscale;
617 ret = sh_mobile_lcdc_check_var(&var, info);
689 for (i = 0; i <
ARRAY_SIZE(sh_mobile_format_infos); ++
i) {
690 if (sh_mobile_format_infos[i].fourcc == fourcc)
691 return &sh_mobile_format_infos[
i];
723 static irqreturn_t sh_mobile_lcdc_irq(
int irq,
void *data)
727 unsigned long ldintr;
732 ldintr = lcdc_read(priv,
_LDINTR);
747 if (is_sub == lcdc_chan_is_sublcd(ch)) {
751 sh_mobile_lcdc_clk_off(priv);
765 unsigned long ldintr;
797 if (lcdc_read(priv,
_LDCNT2R) & priv->
ch[
k].enabled)
799 tmp = lcdc_read_chan(&priv->
ch[k],
LDPMR)
803 if (!start && tmp == 0)
816 unsigned long h_total, hsync_pos, display_h_total;
827 lcdc_write_chan(ch,
LDMT1R, tmp);
830 lcdc_write_chan(ch,
LDMT2R, ch->
cfg->sys_bus_cfg.ldmt2r);
831 lcdc_write_chan(ch,
LDMT3R, ch->
cfg->sys_bus_cfg.ldmt3r);
838 lcdc_write_chan(ch,
LDHCNR, tmp);
843 lcdc_write_chan(ch,
LDHSYNR, tmp);
849 lcdc_write_chan(ch,
LDVLNR, tmp);
853 lcdc_write_chan(ch,
LDVSYNR, tmp);
858 tmp = ((mode->
xres & 7) << 24) | ((display_h_total & 7) << 16)
859 | ((mode->
hsync_len & 7) << 8) | (hsync_pos & 7);
860 lcdc_write_chan(ch,
LDHAJR, tmp);
890 switch (ovl->
format->fourcc) {
909 switch (ovl->
format->fourcc) {
969 lcdc_write(priv,
_LDCNT2R, priv->
ch[0].enabled | priv->
ch[1].enabled);
972 sh_mobile_lcdc_start_stop(priv, 0);
983 lcdc_write_chan(ch,
LDPMR, 0);
985 m = ch->
cfg->clock_divider;
993 lcdc_write_chan(ch,
LDDCKPAT2R, (1 << (m/2)) - 1);
997 tmp |= m << (lcdc_chan_is_sublcd(ch) ? 8 : 0);
1000 lcdc_write(priv,
_LDDCKR, tmp);
1010 sh_mobile_lcdc_geometry(ch);
1025 lcdc_write_chan(ch,
LDDFR, tmp);
1036 ch->
cfg->sys_bus_cfg.deferred_io_msec) {
1040 lcdc_write_chan(ch,
LDSM1R, 0);
1045 switch (priv->
ch[0].format->fourcc) {
1063 lcdc_write(priv,
_LDDDSR, tmp);
1067 sh_mobile_lcdc_start_stop(priv, 1);
1081 if (priv->
ch[k].enabled)
1082 sh_mobile_lcdc_clk_on(priv);
1096 panel = &ch->
cfg->panel_cfg;
1098 ret = panel->
setup_sys(ch, &sh_mobile_lcdc_sys_bus_ops);
1128 switch (ch->
format->fourcc) {
1150 if (!IS_ERR(cache)) {
1160 sh_mobile_lcdc_overlay_setup(ovl);
1164 __sh_mobile_lcdc_start(priv);
1174 tmp = ch->
cfg->sys_bus_cfg.deferred_io_msec;
1176 ch->
defio.deferred_io = sh_mobile_lcdc_deferred_io;
1182 sh_mobile_lcdc_display_on(ch);
1186 backlight_update_status(ch->
bl);
1208 if (ch->
info && ch->
info->fbdefio) {
1214 sh_mobile_lcdc_clk_on(priv);
1219 backlight_update_status(ch->
bl);
1222 sh_mobile_lcdc_display_off(ch);
1234 sh_mobile_lcdc_start_stop(priv, 0);
1240 if (priv->
ch[k].enabled)
1241 sh_mobile_lcdc_clk_off(priv);
1258 if (sh_mobile_format_is_fourcc(var)) {
1261 format = sh_mobile_format_info(var->
grayscale);
1276 var->
red.offset = 11;
1277 var->
red.length = 5;
1278 var->
green.offset = 5;
1279 var->
green.length = 6;
1280 var->
blue.offset = 0;
1281 var->
blue.length = 5;
1286 var->
red.offset = 16;
1287 var->
red.length = 8;
1288 var->
green.offset = 8;
1289 var->
green.length = 8;
1290 var->
blue.offset = 0;
1291 var->
blue.length = 8;
1296 var->
red.offset = 16;
1297 var->
red.length = 8;
1298 var->
green.offset = 8;
1299 var->
green.length = 8;
1300 var->
blue.offset = 0;
1301 var->
blue.length = 8;
1307 var->
red.msb_right = 0;
1308 var->
green.msb_right = 0;
1309 var->
blue.msb_right = 0;
1310 var->
transp.msb_right = 0;
1347 if (endp - buf != count)
1353 if (ovl->
alpha != alpha) {
1357 sh_mobile_lcdc_overlay_setup(ovl);
1374 const char *buf,
size_t count)
1385 if (endp - buf != count)
1391 if (ovl->
mode != mode) {
1395 sh_mobile_lcdc_overlay_setup(ovl);
1413 const char *buf,
size_t count)
1429 if (endp - buf != count)
1432 if (ovl->
pos_x != pos_x || ovl->
pos_y != pos_y) {
1437 sh_mobile_lcdc_overlay_setup(ovl);
1454 const char *buf,
size_t count)
1465 if (endp - buf != count)
1471 if (ovl->
rop3 != rop3) {
1475 sh_mobile_lcdc_overlay_setup(ovl);
1483 overlay_alpha_show, overlay_alpha_store),
1485 overlay_mode_show, overlay_mode_store),
1487 overlay_position_show, overlay_position_store),
1489 overlay_rop3_show, overlay_rop3_store),
1493 .id =
"SH Mobile LCDC",
1509 unsigned long y_offset;
1510 unsigned long c_offset;
1517 unsigned int xsub = ovl->
format->bpp < 24 ? 2 : 1;
1518 unsigned int ysub = ovl->
format->bpp < 16 ? 2 : 1;
1551 static int sh_mobile_lcdc_overlay_ioctl(
struct fb_info *info,
unsigned int cmd,
1558 return sh_mobile_lcdc_wait_for_vsync(ovl->
channel);
1568 return __sh_mobile_lcdc_check_var(var, info);
1571 static int sh_mobile_lcdc_overlay_set_par(
struct fb_info *info)
1576 sh_mobile_format_info(sh_mobile_format_fourcc(&info->
var));
1584 ovl->
pitch = info->
var.xres_virtual;
1588 sh_mobile_lcdc_overlay_setup(ovl);
1590 info->
fix.line_length = ovl->
pitch;
1592 if (sh_mobile_format_is_fourcc(&info->
var)) {
1604 static int sh_mobile_lcdc_overlay_blank(
int blank,
struct fb_info *info)
1609 sh_mobile_lcdc_overlay_setup(ovl);
1617 static struct fb_ops sh_mobile_lcdc_overlay_ops = {
1624 .fb_blank = sh_mobile_lcdc_overlay_blank,
1625 .fb_pan_display = sh_mobile_lcdc_overlay_pan,
1626 .fb_ioctl = sh_mobile_lcdc_overlay_ioctl,
1627 .fb_check_var = sh_mobile_lcdc_overlay_check_var,
1628 .fb_set_par = sh_mobile_lcdc_overlay_set_par,
1657 dev_info(lcdc->
dev,
"registered %s/overlay %u as %dx%d %dbpp.\n",
1659 info->
var.yres, info->
var.bits_per_pixel);
1661 for (i = 0; i <
ARRAY_SIZE(overlay_sysfs_attrs); ++
i) {
1691 dev_err(priv->
dev,
"unable to allocate fb_info\n");
1698 info->
fbops = &sh_mobile_lcdc_overlay_ops;
1706 info->
fix = sh_mobile_lcdc_overlay_fix;
1708 "SH Mobile LCDC Overlay %u", ovl->
index);
1711 info->
fix.line_length = ovl->
pitch;
1718 switch (ovl->
format->fourcc) {
1721 info->
fix.ypanstep = 2;
1724 info->
fix.xpanstep = 2;
1729 memset(var, 0,
sizeof(*var));
1744 return sh_mobile_lcdc_overlay_check_var(var, info);
1751 static int sh_mobile_lcdc_setcolreg(
u_int regno,
1762 red >>= 16 - info->
var.red.length;
1763 green >>= 16 - info->
var.green.length;
1764 blue >>= 16 - info->
var.blue.length;
1765 transp >>= 16 - info->
var.transp.length;
1767 palette[regno] = (red << info->
var.red.offset) |
1768 (green << info->
var.green.offset) |
1769 (blue << info->
var.blue.offset) |
1770 (transp << info->
var.transp.offset);
1776 .id =
"SH Mobile LCDC",
1786 static void sh_mobile_lcdc_fillrect(
struct fb_info *info,
1790 sh_mobile_lcdc_deferred_io_touch(info);
1793 static void sh_mobile_lcdc_copyarea(
struct fb_info *info,
1797 sh_mobile_lcdc_deferred_io_touch(info);
1800 static void sh_mobile_lcdc_imageblit(
struct fb_info *info,
1804 sh_mobile_lcdc_deferred_io_touch(info);
1812 unsigned long ldrcntr;
1813 unsigned long base_addr_y, base_addr_c;
1814 unsigned long y_offset;
1815 unsigned long c_offset;
1822 unsigned int xsub = ch->
format->bpp < 24 ? 2 : 1;
1823 unsigned int ysub = ch->
format->bpp < 16 ? 2 : 1;
1843 base_addr_y, base_addr_c,
1844 &base_addr_y, &base_addr_c);
1850 lcdc_write_chan_mirror(ch,
LDSA1R, base_addr_y);
1852 lcdc_write_chan_mirror(ch,
LDSA2R, base_addr_c);
1854 ldrcntr = lcdc_read(priv,
_LDRCNTR);
1855 if (lcdc_chan_is_sublcd(ch))
1861 sh_mobile_lcdc_deferred_io_touch(info);
1866 static int sh_mobile_lcdc_ioctl(
struct fb_info *info,
unsigned int cmd,
1874 retval = sh_mobile_lcdc_wait_for_vsync(ch);
1884 static void sh_mobile_fb_reconfig(
struct fb_info *info)
1918 event.data = &ch->
display.mode;
1926 static int sh_mobile_lcdc_release(
struct fb_info *info,
int user)
1938 sh_mobile_fb_reconfig(info);
1947 static int sh_mobile_lcdc_open(
struct fb_info *info,
int user)
1965 unsigned int best_dist = (
unsigned int)-1;
1966 unsigned int best_xres = 0;
1967 unsigned int best_yres = 0;
1976 for (i = 0; i < ch->
cfg->num_modes; ++
i) {
1988 if (dist < best_dist) {
1989 best_xres = mode->
xres;
1990 best_yres = mode->
yres;
1996 if (ch->
cfg->num_modes != 0) {
1997 if (best_dist == (
unsigned int)-1)
2000 var->
xres = best_xres;
2001 var->
yres = best_yres;
2004 ret = __sh_mobile_lcdc_check_var(var, info);
2016 static int sh_mobile_lcdc_set_par(
struct fb_info *info)
2021 sh_mobile_lcdc_stop(ch->
lcdc);
2023 ch->
format = sh_mobile_format_info(sh_mobile_format_fourcc(&info->
var));
2032 ch->
pitch = info->
var.xres_virtual;
2036 ret = sh_mobile_lcdc_start(ch->
lcdc);
2038 dev_err(info->
dev,
"%s: unable to restart LCDC\n", __func__);
2042 if (sh_mobile_format_is_fourcc(&info->
var)) {
2061 static int sh_mobile_lcdc_blank(
int blank,
struct fb_info *info)
2072 sh_mobile_lcdc_fillrect(info, &rect);
2076 sh_mobile_lcdc_clk_on(p);
2085 if (!info->fbdefio) {
2086 sh_mobile_lcdc_wait_for_vsync(ch);
2087 sh_mobile_lcdc_wait_for_vsync(ch);
2089 sh_mobile_lcdc_clk_off(p);
2096 static struct fb_ops sh_mobile_lcdc_ops = {
2098 .fb_setcolreg = sh_mobile_lcdc_setcolreg,
2101 .fb_fillrect = sh_mobile_lcdc_fillrect,
2102 .fb_copyarea = sh_mobile_lcdc_copyarea,
2103 .fb_imageblit = sh_mobile_lcdc_imageblit,
2104 .fb_blank = sh_mobile_lcdc_blank,
2105 .fb_pan_display = sh_mobile_lcdc_pan,
2106 .fb_ioctl = sh_mobile_lcdc_ioctl,
2107 .fb_open = sh_mobile_lcdc_open,
2108 .fb_release = sh_mobile_lcdc_release,
2109 .fb_check_var = sh_mobile_lcdc_check_var,
2110 .fb_set_par = sh_mobile_lcdc_set_par,
2126 if (info->fbdefio) {
2130 dev_err(ch->
lcdc->dev,
"cannot allocate sglist\n");
2135 info->bl_dev = ch->
bl;
2141 dev_info(ch->
lcdc->dev,
"registered %s/%s as %dx%d %dbpp.\n",
2143 "mainlcd" :
"sublcd", info->
var.xres, info->
var.yres,
2144 info->
var.bits_per_pixel);
2148 sh_mobile_lcdc_clk_off(ch->
lcdc);
2158 if (!info || !info->
device)
2171 unsigned int num_modes)
2183 dev_err(priv->
dev,
"unable to allocate fb_info\n");
2190 info->
fbops = &sh_mobile_lcdc_ops;
2200 dev_err(priv->
dev,
"unable to allocate cmap\n");
2207 info->
fix = sh_mobile_lcdc_fix;
2217 switch (ch->
format->fourcc) {
2220 info->
fix.ypanstep = 2;
2223 info->
fix.xpanstep = 2;
2231 var->
width = ch->
cfg->panel_cfg.width;
2232 var->
height = ch->
cfg->panel_cfg.height;
2245 ret = sh_mobile_lcdc_check_var(var, info);
2265 return ch->
cfg->bl_info.set_brightness(brightness);
2272 return ch->
cfg->bl_info.get_brightness();
2278 return (info->bl_dev == bdev);
2283 .update_status = sh_mobile_lcdc_update_bl,
2284 .get_brightness = sh_mobile_lcdc_get_brightness,
2285 .check_fb = sh_mobile_lcdc_check_fb,
2294 &sh_mobile_lcdc_bl_ops,
NULL);
2296 dev_err(parent,
"unable to register backlight device: %ld\n",
2301 bl->
props.max_brightness = ch->
cfg->bl_info.max_brightness;
2302 bl->
props.brightness = bl->
props.max_brightness;
2303 backlight_update_status(bl);
2317 static int sh_mobile_lcdc_suspend(
struct device *dev)
2321 sh_mobile_lcdc_stop(platform_get_drvdata(pdev));
2325 static int sh_mobile_lcdc_resume(
struct device *dev)
2329 return sh_mobile_lcdc_start(platform_get_drvdata(pdev));
2332 static int sh_mobile_lcdc_runtime_suspend(
struct device *dev)
2343 static int sh_mobile_lcdc_runtime_resume(
struct device *dev)
2348 __sh_mobile_lcdc_start(priv);
2353 static const struct dev_pm_ops sh_mobile_lcdc_dev_pm_ops = {
2354 .suspend = sh_mobile_lcdc_suspend,
2355 .resume = sh_mobile_lcdc_resume,
2356 .runtime_suspend = sh_mobile_lcdc_runtime_suspend,
2357 .runtime_resume = sh_mobile_lcdc_runtime_resume,
2366 unsigned long action,
void *data)
2369 struct fb_info *info =
event->info;
2372 if (&ch->
lcdc->notifier != nb)
2375 dev_dbg(info->
dev,
"%s(): action = %lu, data = %p\n",
2376 __func__, action, event->data);
2380 sh_mobile_lcdc_display_off(ch);
2381 sh_mobile_lcdc_stop(ch->
lcdc);
2385 sh_mobile_fb_reconfig(info);
2388 sh_mobile_lcdc_display_on(ch);
2389 sh_mobile_lcdc_start(ch->
lcdc);
2400 .name =
"HDMI 720p",
2405 .right_margin = 110,
2425 sh_mobile_lcdc_overlay_fb_unregister(&priv->
overlays[i]);
2427 sh_mobile_lcdc_channel_fb_unregister(&priv->
ch[i]);
2429 sh_mobile_lcdc_stop(priv);
2434 sh_mobile_lcdc_overlay_fb_cleanup(ovl);
2446 module_put(ch->
cfg->tx_dev->dev.driver->owner);
2449 sh_mobile_lcdc_channel_fb_cleanup(ch);
2460 sh_mobile_lcdc_bl_remove(ch->
bl);
2465 pm_runtime_disable(&pdev->
dev);
2482 switch (interface_type) {
2507 if (lcdc_chan_is_sublcd(ch)) {
2511 interface_type &= ~LDMT1R_IFM;
2525 if (ovl->
cfg->fourcc == 0)
2529 format = sh_mobile_format_info(ovl->
cfg->fourcc);
2530 if (format ==
NULL) {
2531 dev_err(priv->
dev,
"Invalid FOURCC %08x\n", ovl->
cfg->fourcc);
2546 ovl->
xres = ovl->
cfg->max_xres;
2548 ovl->
yres = ovl->
cfg->max_yres;
2558 * format->
bpp / 8 * 2;
2562 dev_err(priv->
dev,
"unable to allocate buffer\n");
2566 ret = sh_mobile_lcdc_overlay_fb_init(ovl);
2581 unsigned int num_modes;
2586 ch->
notify = sh_mobile_lcdc_display_notify;
2589 format = sh_mobile_format_info(cfg->
fourcc);
2590 if (format ==
NULL) {
2601 for (i = 0, mode = cfg->
lcd_modes; i < cfg->num_modes; i++, mode++) {
2607 dev_err(priv->
dev,
"yres must be multiple of 2 for "
2608 "YCbCr420 mode.\n");
2612 if (size > max_size) {
2621 dev_dbg(priv->
dev,
"Found largest videomode %ux%u\n",
2625 mode = &default_720p;
2654 ch->
fb_size = max_size * format->
bpp / 8 * 2;
2658 dev_err(priv->
dev,
"unable to allocate buffer\n");
2664 if (!cfg->
tx_dev->dev.driver ||
2665 !try_module_get(cfg->
tx_dev->dev.driver->owner)) {
2667 "unable to get transmitter device\n");
2675 return sh_mobile_lcdc_channel_fb_init(ch, mode, num_modes);
2688 dev_err(&pdev->
dev,
"no platform data defined\n");
2694 if (!res || i < 0) {
2695 dev_err(&pdev->
dev,
"cannot get platform resources\n");
2701 dev_err(&pdev->
dev,
"cannot allocate device data\n");
2707 platform_set_drvdata(pdev, priv);
2710 dev_name(&pdev->
dev), priv);
2712 dev_err(&pdev->
dev,
"unable to request irq\n");
2719 for (i = 0, num_channels = 0; i <
ARRAY_SIZE(pdata->
ch); i++) {
2725 error = sh_mobile_lcdc_check_interface(ch);
2727 dev_err(&pdev->
dev,
"unsupported interface type\n");
2734 if (ch->
cfg->bl_info.max_brightness)
2735 ch->
bl = sh_mobile_lcdc_bl_probe(&pdev->
dev, ch);
2737 switch (pdata->
ch[i].chan) {
2751 if (!num_channels) {
2752 dev_err(&pdev->
dev,
"no channels defined\n");
2758 if (num_channels == 2)
2765 error = sh_mobile_lcdc_setup_clocks(priv, pdata->
clock_source);
2767 dev_err(&pdev->
dev,
"unable to setup clocks\n");
2777 error = sh_mobile_lcdc_channel_init(priv, ch);
2788 error = sh_mobile_lcdc_overlay_init(priv, ovl);
2793 error = sh_mobile_lcdc_start(priv);
2795 dev_err(&pdev->
dev,
"unable to start hardware\n");
2802 error = sh_mobile_lcdc_channel_fb_register(ch);
2810 error = sh_mobile_lcdc_overlay_fb_register(ovl);
2816 priv->
notifier.notifier_call = sh_mobile_lcdc_notify;
2821 sh_mobile_lcdc_remove(pdev);
2828 .name =
"sh_mobile_lcdc_fb",
2830 .pm = &sh_mobile_lcdc_dev_pm_ops,
2832 .probe = sh_mobile_lcdc_probe,
2833 .remove = sh_mobile_lcdc_remove,