Lines Matching +full:sync +full:- +full:on +full:- +full:green

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 1998-2002 Russell King
15 * Based on cyberfb.c.
22 * are any such cards, but I'm erring on the side of caution. We don't
49 #include <linux/i2c-algo-bit.h>
53 #include <asm/mach-types.h>
74 u8 red, green, blue; member
110 #define cyber2000fb_writel(val, reg, cfb) writel(val, (cfb)->regs + (reg))
111 #define cyber2000fb_writew(val, reg, cfb) writew(val, (cfb)->regs + (reg))
112 #define cyber2000fb_writeb(val, reg, cfb) writeb(val, (cfb)->regs + (reg))
114 #define cyber2000fb_readb(reg, cfb) readb((cfb)->regs + (reg))
150 /* -------------------- Hardware specific routines ------------------------- */
161 if (!(cfb->fb.var.accel_flags & FB_ACCELF_TEXT)) { in cyber2000fb_fillrect()
167 cyber2000fb_writew(rect->width - 1, CO_REG_PIXWIDTH, cfb); in cyber2000fb_fillrect()
168 cyber2000fb_writew(rect->height - 1, CO_REG_PIXHEIGHT, cfb); in cyber2000fb_fillrect()
170 col = rect->color; in cyber2000fb_fillrect()
171 if (cfb->fb.var.bits_per_pixel > 8) in cyber2000fb_fillrect()
172 col = ((u32 *)cfb->fb.pseudo_palette)[col]; in cyber2000fb_fillrect()
175 dst = rect->dx + rect->dy * cfb->fb.var.xres_virtual; in cyber2000fb_fillrect()
176 if (cfb->fb.var.bits_per_pixel == 24) { in cyber2000fb_fillrect()
194 if (!(cfb->fb.var.accel_flags & FB_ACCELF_TEXT)) { in cyber2000fb_copyarea()
200 cyber2000fb_writew(region->width - 1, CO_REG_PIXWIDTH, cfb); in cyber2000fb_copyarea()
201 cyber2000fb_writew(region->height - 1, CO_REG_PIXHEIGHT, cfb); in cyber2000fb_copyarea()
203 src = region->sx + region->sy * cfb->fb.var.xres_virtual; in cyber2000fb_copyarea()
204 dst = region->dx + region->dy * cfb->fb.var.xres_virtual; in cyber2000fb_copyarea()
206 if (region->sx < region->dx) { in cyber2000fb_copyarea()
207 src += region->width - 1; in cyber2000fb_copyarea()
208 dst += region->width - 1; in cyber2000fb_copyarea()
212 if (region->sy < region->dy) { in cyber2000fb_copyarea()
213 src += (region->height - 1) * cfb->fb.var.xres_virtual; in cyber2000fb_copyarea()
214 dst += (region->height - 1) * cfb->fb.var.xres_virtual; in cyber2000fb_copyarea()
218 if (cfb->fb.var.bits_per_pixel == 24) { in cyber2000fb_copyarea()
243 if (!(cfb->fb.var.accel_flags & FB_ACCELF_TEXT)) in cyber2000fb_sync()
247 if (!count--) { in cyber2000fb_sync()
263 u_int mask = (1 << bf->length) - 1; in convert_bitfield()
265 return (val >> (16 - bf->length) & mask) << bf->offset; in convert_bitfield()
272 cyber2000fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, in cyber2000fb_setcolreg() argument
276 struct fb_var_screeninfo *var = &cfb->fb.var; in cyber2000fb_setcolreg()
280 switch (cfb->fb.fix.visual) { in cyber2000fb_setcolreg()
287 * pixel --/--+--/--> red lut --> red dac in cyber2000fb_setcolreg()
289 * +--/--> green lut --> green dac in cyber2000fb_setcolreg()
291 * +--/--> blue lut --> blue dac in cyber2000fb_setcolreg()
298 green >>= 8; in cyber2000fb_setcolreg()
301 cfb->palette[regno].red = red; in cyber2000fb_setcolreg()
302 cfb->palette[regno].green = green; in cyber2000fb_setcolreg()
303 cfb->palette[regno].blue = blue; in cyber2000fb_setcolreg()
307 cyber2000fb_writeb(green, 0x3c9, cfb); in cyber2000fb_setcolreg()
314 * pixel --/--+--/--> red lut --> red dac in cyber2000fb_setcolreg()
316 * +--/--> green lut --> green dac in cyber2000fb_setcolreg()
318 * +--/--> blue lut --> blue dac in cyber2000fb_setcolreg()
319 * n = bpp, rl = red length, gl = green length, bl = blue length in cyber2000fb_setcolreg()
323 green >>= 8; in cyber2000fb_setcolreg()
326 if (var->green.length == 6 && regno < 64) { in cyber2000fb_setcolreg()
327 cfb->palette[regno << 2].green = green; in cyber2000fb_setcolreg()
330 * The 6 bits of the green component are applied in cyber2000fb_setcolreg()
334 cyber2000fb_writeb(cfb->palette[regno >> 1].red, in cyber2000fb_setcolreg()
336 cyber2000fb_writeb(green, 0x3c9, cfb); in cyber2000fb_setcolreg()
337 cyber2000fb_writeb(cfb->palette[regno >> 1].blue, in cyber2000fb_setcolreg()
340 green = cfb->palette[regno << 3].green; in cyber2000fb_setcolreg()
345 if (var->green.length >= 5 && regno < 32) { in cyber2000fb_setcolreg()
346 cfb->palette[regno << 3].red = red; in cyber2000fb_setcolreg()
347 cfb->palette[regno << 3].green = green; in cyber2000fb_setcolreg()
348 cfb->palette[regno << 3].blue = blue; in cyber2000fb_setcolreg()
356 cyber2000fb_writeb(green, 0x3c9, cfb); in cyber2000fb_setcolreg()
361 if (var->green.length == 4 && regno < 16) { in cyber2000fb_setcolreg()
362 cfb->palette[regno << 4].red = red; in cyber2000fb_setcolreg()
363 cfb->palette[regno << 4].green = green; in cyber2000fb_setcolreg()
364 cfb->palette[regno << 4].blue = blue; in cyber2000fb_setcolreg()
372 cyber2000fb_writeb(green, 0x3c9, cfb); in cyber2000fb_setcolreg()
381 pseudo_val = regno << var->red.offset | in cyber2000fb_setcolreg()
382 regno << var->green.offset | in cyber2000fb_setcolreg()
383 regno << var->blue.offset; in cyber2000fb_setcolreg()
389 * pixel --/--+--/--> red dac in cyber2000fb_setcolreg()
391 * +--/--> green dac in cyber2000fb_setcolreg()
393 * +--/--> blue dac in cyber2000fb_setcolreg()
394 * n = bpp, rl = red length, gl = green length, bl = blue length in cyber2000fb_setcolreg()
397 pseudo_val = convert_bitfield(transp ^ 0xffff, &var->transp); in cyber2000fb_setcolreg()
398 pseudo_val |= convert_bitfield(red, &var->red); in cyber2000fb_setcolreg()
399 pseudo_val |= convert_bitfield(green, &var->green); in cyber2000fb_setcolreg()
400 pseudo_val |= convert_bitfield(blue, &var->blue); in cyber2000fb_setcolreg()
409 ((u32 *)cfb->fb.pseudo_palette)[regno] = pseudo_val; in cyber2000fb_setcolreg()
443 unsigned int val = cfb->ramdac_ctrl | cfb->ramdac_powerdown; in cyber2000fb_write_ramdac_ctrl()
450 /* prevent card lock-up observed on x86 with CyberPro 2000 */ in cyber2000fb_write_ramdac_ctrl()
480 cyber2000_crtcw(crtc_idx[i], hw->crtc[i], cfb); in cyber2000fb_set_timing()
485 cyber2000_grphw(EXT_CRT_VRTOFL, hw->crtc_ofl, cfb); in cyber2000fb_set_timing()
507 spin_lock(&cfb->reg_b0_lock); in cyber2000fb_set_timing()
508 cyber2000_grphw(EXT_DCLK_MULT, hw->clock_mult, cfb); in cyber2000fb_set_timing()
509 cyber2000_grphw(EXT_DCLK_DIV, hw->clock_div, cfb); in cyber2000fb_set_timing()
510 cyber2000_grphw(EXT_MCLK_MULT, cfb->mclk_mult, cfb); in cyber2000fb_set_timing()
511 cyber2000_grphw(EXT_MCLK_DIV, cfb->mclk_div, cfb); in cyber2000fb_set_timing()
515 spin_unlock(&cfb->reg_b0_lock); in cyber2000fb_set_timing()
517 cfb->ramdac_ctrl = hw->ramdac; in cyber2000fb_set_timing()
523 cyber2000_grphw(0x14, hw->fetch, cfb); in cyber2000fb_set_timing()
524 cyber2000_grphw(0x15, ((hw->fetch >> 8) & 0x03) | in cyber2000fb_set_timing()
525 ((hw->pitch >> 4) & 0x30), cfb); in cyber2000fb_set_timing()
526 cyber2000_grphw(EXT_SEQ_MISC, hw->extseqmisc, cfb); in cyber2000fb_set_timing()
531 cyber2000fb_writew(hw->width, CO_REG_SRC_WIDTH, cfb); in cyber2000fb_set_timing()
532 cyber2000fb_writew(hw->width, CO_REG_DEST_WIDTH, cfb); in cyber2000fb_set_timing()
533 cyber2000fb_writeb(hw->co_pixfmt, CO_REG_PIXFMT, cfb); in cyber2000fb_set_timing()
539 u_int base = var->yoffset * var->xres_virtual + var->xoffset; in cyber2000fb_update_start()
541 base *= var->bits_per_pixel; in cyber2000fb_update_start()
545 * can only start on 4 byte aligned data. in cyber2000fb_update_start()
550 return -EINVAL; in cyber2000fb_update_start()
567 hw->crtc[13] = hw->pitch; in cyber2000fb_decode_crtc()
568 hw->crtc[17] = 0xe3; in cyber2000fb_decode_crtc()
569 hw->crtc[14] = 0; in cyber2000fb_decode_crtc()
570 hw->crtc[8] = 0; in cyber2000fb_decode_crtc()
572 Htotal = var->xres + var->right_margin + in cyber2000fb_decode_crtc()
573 var->hsync_len + var->left_margin; in cyber2000fb_decode_crtc()
576 return -EINVAL; in cyber2000fb_decode_crtc()
578 hw->crtc[0] = (Htotal >> 3) - 5; in cyber2000fb_decode_crtc()
579 hw->crtc[1] = (var->xres >> 3) - 1; in cyber2000fb_decode_crtc()
580 hw->crtc[2] = var->xres >> 3; in cyber2000fb_decode_crtc()
581 hw->crtc[4] = (var->xres + var->right_margin) >> 3; in cyber2000fb_decode_crtc()
583 Hblankend = (Htotal - 4 * 8) >> 3; in cyber2000fb_decode_crtc()
585 hw->crtc[3] = ENCODE_BIT(Hblankend, 0, 0x1f, 0) | in cyber2000fb_decode_crtc()
588 Hsyncend = (var->xres + var->right_margin + var->hsync_len) >> 3; in cyber2000fb_decode_crtc()
590 hw->crtc[5] = ENCODE_BIT(Hsyncend, 0, 0x1f, 0) | in cyber2000fb_decode_crtc()
593 Vdispend = var->yres - 1; in cyber2000fb_decode_crtc()
594 Vsyncstart = var->yres + var->lower_margin; in cyber2000fb_decode_crtc()
595 Vsyncend = var->yres + var->lower_margin + var->vsync_len; in cyber2000fb_decode_crtc()
596 Vtotal = var->yres + var->lower_margin + var->vsync_len + in cyber2000fb_decode_crtc()
597 var->upper_margin - 2; in cyber2000fb_decode_crtc()
600 return -EINVAL; in cyber2000fb_decode_crtc()
602 Vblankstart = var->yres + 6; in cyber2000fb_decode_crtc()
603 Vblankend = Vtotal - 10; in cyber2000fb_decode_crtc()
605 hw->crtc[6] = Vtotal; in cyber2000fb_decode_crtc()
606 hw->crtc[7] = ENCODE_BIT(Vtotal, 8, 0x01, 0) | in cyber2000fb_decode_crtc()
614 hw->crtc[9] = ENCODE_BIT(0, 0, 0x1f, 0) | in cyber2000fb_decode_crtc()
617 hw->crtc[10] = Vsyncstart; in cyber2000fb_decode_crtc()
618 hw->crtc[11] = ENCODE_BIT(Vsyncend, 0, 0x0f, 0) | in cyber2000fb_decode_crtc()
620 hw->crtc[12] = Vdispend; in cyber2000fb_decode_crtc()
621 hw->crtc[15] = Vblankstart; in cyber2000fb_decode_crtc()
622 hw->crtc[16] = Vblankend; in cyber2000fb_decode_crtc()
623 hw->crtc[18] = 0xff; in cyber2000fb_decode_crtc()
626 * overflow - graphics reg 0x11 in cyber2000fb_decode_crtc()
628 * 4=LINECOMP:10 5-IVIDEO 6=FIXCNT in cyber2000fb_decode_crtc()
630 hw->crtc_ofl = in cyber2000fb_decode_crtc()
639 if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) in cyber2000fb_decode_crtc()
640 hw->crtc_ofl |= EXT_CRT_VRTOFL_INTERLACE; in cyber2000fb_decode_crtc()
664 u_long pll_ps = var->pixclock; in cyber2000fb_decode_clock()
665 const u_long ref_ps = cfb->ref_ps; in cyber2000fb_decode_clock()
678 new_pll = pll_ps / cfb->divisors[div2]; in cyber2000fb_decode_clock()
686 return -EINVAL; in cyber2000fb_decode_clock()
719 diff = pll_ps - t_pll_ps; in cyber2000fb_decode_clock()
721 diff = -diff; in cyber2000fb_decode_clock()
740 hw->clock_mult = best_mult - 1; in cyber2000fb_decode_clock()
741 hw->clock_div = div2 << 6 | (best_div1 - 1); in cyber2000fb_decode_clock()
746 hw->clock_div |= EXT_DCLK_DIV_VFSEL; in cyber2000fb_decode_clock()
762 var->transp.msb_right = 0; in cyber2000fb_check_var()
763 var->red.msb_right = 0; in cyber2000fb_check_var()
764 var->green.msb_right = 0; in cyber2000fb_check_var()
765 var->blue.msb_right = 0; in cyber2000fb_check_var()
766 var->transp.offset = 0; in cyber2000fb_check_var()
767 var->transp.length = 0; in cyber2000fb_check_var()
769 switch (var->bits_per_pixel) { in cyber2000fb_check_var()
771 var->red.offset = 0; in cyber2000fb_check_var()
772 var->red.length = 8; in cyber2000fb_check_var()
773 var->green.offset = 0; in cyber2000fb_check_var()
774 var->green.length = 8; in cyber2000fb_check_var()
775 var->blue.offset = 0; in cyber2000fb_check_var()
776 var->blue.length = 8; in cyber2000fb_check_var()
780 switch (var->green.length) { in cyber2000fb_check_var()
782 var->red.offset = 11; in cyber2000fb_check_var()
783 var->red.length = 5; in cyber2000fb_check_var()
784 var->green.offset = 5; in cyber2000fb_check_var()
785 var->green.length = 6; in cyber2000fb_check_var()
786 var->blue.offset = 0; in cyber2000fb_check_var()
787 var->blue.length = 5; in cyber2000fb_check_var()
792 var->red.offset = 10; in cyber2000fb_check_var()
793 var->red.length = 5; in cyber2000fb_check_var()
794 var->green.offset = 5; in cyber2000fb_check_var()
795 var->green.length = 5; in cyber2000fb_check_var()
796 var->blue.offset = 0; in cyber2000fb_check_var()
797 var->blue.length = 5; in cyber2000fb_check_var()
801 var->transp.offset = 12; in cyber2000fb_check_var()
802 var->transp.length = 4; in cyber2000fb_check_var()
803 var->red.offset = 8; in cyber2000fb_check_var()
804 var->red.length = 4; in cyber2000fb_check_var()
805 var->green.offset = 4; in cyber2000fb_check_var()
806 var->green.length = 4; in cyber2000fb_check_var()
807 var->blue.offset = 0; in cyber2000fb_check_var()
808 var->blue.length = 4; in cyber2000fb_check_var()
814 var->red.offset = 16; in cyber2000fb_check_var()
815 var->red.length = 8; in cyber2000fb_check_var()
816 var->green.offset = 8; in cyber2000fb_check_var()
817 var->green.length = 8; in cyber2000fb_check_var()
818 var->blue.offset = 0; in cyber2000fb_check_var()
819 var->blue.length = 8; in cyber2000fb_check_var()
823 var->transp.offset = 24; in cyber2000fb_check_var()
824 var->transp.length = 8; in cyber2000fb_check_var()
825 var->red.offset = 16; in cyber2000fb_check_var()
826 var->red.length = 8; in cyber2000fb_check_var()
827 var->green.offset = 8; in cyber2000fb_check_var()
828 var->green.length = 8; in cyber2000fb_check_var()
829 var->blue.offset = 0; in cyber2000fb_check_var()
830 var->blue.length = 8; in cyber2000fb_check_var()
834 return -EINVAL; in cyber2000fb_check_var()
837 mem = var->xres_virtual * var->yres_virtual * (var->bits_per_pixel / 8); in cyber2000fb_check_var()
838 if (mem > cfb->fb.fix.smem_len) in cyber2000fb_check_var()
839 var->yres_virtual = cfb->fb.fix.smem_len * 8 / in cyber2000fb_check_var()
840 (var->bits_per_pixel * var->xres_virtual); in cyber2000fb_check_var()
842 if (var->yres > var->yres_virtual) in cyber2000fb_check_var()
843 var->yres = var->yres_virtual; in cyber2000fb_check_var()
844 if (var->xres > var->xres_virtual) in cyber2000fb_check_var()
845 var->xres = var->xres_virtual; in cyber2000fb_check_var()
861 struct fb_var_screeninfo *var = &cfb->fb.var; in cyber2000fb_set_par()
865 hw.width = var->xres_virtual; in cyber2000fb_set_par()
868 switch (var->bits_per_pixel) { in cyber2000fb_set_par()
879 switch (var->green.length) { in cyber2000fb_set_par()
927 hw.width -= 1; in cyber2000fb_set_par()
929 if (!(cfb->mem_ctl2 & MEM_CTL2_64BIT)) in cyber2000fb_set_par()
933 cfb->fb.fix.line_length = var->xres_virtual * var->bits_per_pixel / 8; in cyber2000fb_set_par()
936 * Same here - if the size of the video mode exceeds the in cyber2000fb_set_par()
942 mem = cfb->fb.fix.line_length * var->yres_virtual; in cyber2000fb_set_par()
943 BUG_ON(mem > cfb->fb.fix.smem_len); in cyber2000fb_set_par()
947 * are direct colour or true colour, depending on whether in cyber2000fb_set_par()
951 if (var->bits_per_pixel == 8) in cyber2000fb_set_par()
952 cfb->fb.fix.visual = FB_VISUAL_PSEUDOCOLOR; in cyber2000fb_set_par()
954 cfb->fb.fix.visual = FB_VISUAL_TRUECOLOR; in cyber2000fb_set_par()
956 cfb->fb.fix.visual = FB_VISUAL_DIRECTCOLOR; in cyber2000fb_set_par()
973 return -EINVAL; in cyber2000fb_pan_display()
975 cfb->fb.var.xoffset = var->xoffset; in cyber2000fb_pan_display()
976 cfb->fb.var.yoffset = var->yoffset; in cyber2000fb_pan_display()
978 if (var->vmode & FB_VMODE_YWRAP) { in cyber2000fb_pan_display()
979 cfb->fb.var.vmode |= FB_VMODE_YWRAP; in cyber2000fb_pan_display()
981 cfb->fb.var.vmode &= ~FB_VMODE_YWRAP; in cyber2000fb_pan_display()
993 * succeeded, != 0 if un-/blanking failed due to e.g. a
995 * suspend and powerdown modes on hardware that supports
1002 * run "setterm -powersave powerdown" to take advantage
1007 unsigned int sync = 0; in cyber2000fb_blank() local
1011 case FB_BLANK_POWERDOWN: /* powerdown - both sync lines down */ in cyber2000fb_blank()
1012 sync = EXT_SYNC_CTL_VS_0 | EXT_SYNC_CTL_HS_0; in cyber2000fb_blank()
1015 sync = EXT_SYNC_CTL_VS_NORMAL | EXT_SYNC_CTL_HS_0; in cyber2000fb_blank()
1018 sync = EXT_SYNC_CTL_VS_0 | EXT_SYNC_CTL_HS_NORMAL; in cyber2000fb_blank()
1025 cyber2000_grphw(EXT_SYNC_CTL, sync, cfb); in cyber2000fb_blank()
1028 /* turn on ramdacs */ in cyber2000fb_blank()
1029 cfb->ramdac_powerdown &= ~(RAMDAC_DACPWRDN | RAMDAC_BYPASS | in cyber2000fb_blank()
1047 cyber2000fb_writeb(cfb->palette[i].red, 0x3c9, cfb); in cyber2000fb_blank()
1048 cyber2000fb_writeb(cfb->palette[i].green, 0x3c9, cfb); in cyber2000fb_blank()
1049 cyber2000fb_writeb(cfb->palette[i].blue, 0x3c9, cfb); in cyber2000fb_blank()
1055 cfb->ramdac_powerdown |= RAMDAC_DACPWRDN | RAMDAC_BYPASS | in cyber2000fb_blank()
1088 cfb->func_use_count += 1; in cyber2000fb_enable_extregs()
1090 if (cfb->func_use_count == 1) { in cyber2000fb_enable_extregs()
1105 if (cfb->func_use_count == 1) { in cyber2000fb_disable_extregs()
1113 if (cfb->func_use_count == 0) in cyber2000fb_disable_extregs()
1116 cfb->func_use_count -= 1; in cyber2000fb_disable_extregs()
1126 info->dev = int_cfb_info->fb.device; in cyber2000fb_attach()
1128 info->i2c = &int_cfb_info->i2c_adapter; in cyber2000fb_attach()
1130 info->i2c = NULL; in cyber2000fb_attach()
1132 info->regs = int_cfb_info->regs; in cyber2000fb_attach()
1133 info->irq = int_cfb_info->irq; in cyber2000fb_attach()
1134 info->fb = int_cfb_info->fb.screen_base; in cyber2000fb_attach()
1135 info->fb_size = int_cfb_info->fb.fix.smem_len; in cyber2000fb_attach()
1136 info->info = int_cfb_info; in cyber2000fb_attach()
1138 strscpy(info->dev_name, int_cfb_info->fb.fix.id, in cyber2000fb_attach()
1139 sizeof(info->dev_name)); in cyber2000fb_attach()
1163 __acquires(&cfb->reg_b0_lock) in cyber2000fb_enable_ddc()
1165 spin_lock(&cfb->reg_b0_lock); in cyber2000fb_enable_ddc()
1170 __releases(&cfb->reg_b0_lock) in cyber2000fb_disable_ddc()
1173 spin_unlock(&cfb->reg_b0_lock); in cyber2000fb_disable_ddc()
1233 strscpy(cfb->ddc_adapter.name, cfb->fb.fix.id, in cyber2000fb_setup_ddc_bus()
1234 sizeof(cfb->ddc_adapter.name)); in cyber2000fb_setup_ddc_bus()
1235 cfb->ddc_adapter.owner = THIS_MODULE; in cyber2000fb_setup_ddc_bus()
1236 cfb->ddc_adapter.class = I2C_CLASS_DDC; in cyber2000fb_setup_ddc_bus()
1237 cfb->ddc_adapter.algo_data = &cfb->ddc_algo; in cyber2000fb_setup_ddc_bus()
1238 cfb->ddc_adapter.dev.parent = cfb->fb.device; in cyber2000fb_setup_ddc_bus()
1239 cfb->ddc_algo.setsda = cyber2000fb_ddc_setsda; in cyber2000fb_setup_ddc_bus()
1240 cfb->ddc_algo.setscl = cyber2000fb_ddc_setscl; in cyber2000fb_setup_ddc_bus()
1241 cfb->ddc_algo.getsda = cyber2000fb_ddc_getsda; in cyber2000fb_setup_ddc_bus()
1242 cfb->ddc_algo.getscl = cyber2000fb_ddc_getscl; in cyber2000fb_setup_ddc_bus()
1243 cfb->ddc_algo.udelay = 10; in cyber2000fb_setup_ddc_bus()
1244 cfb->ddc_algo.timeout = 20; in cyber2000fb_setup_ddc_bus()
1245 cfb->ddc_algo.data = cfb; in cyber2000fb_setup_ddc_bus()
1247 i2c_set_adapdata(&cfb->ddc_adapter, cfb); in cyber2000fb_setup_ddc_bus()
1249 return i2c_bit_add_bus(&cfb->ddc_adapter); in cyber2000fb_setup_ddc_bus()
1259 spin_lock(&cfb->reg_b0_lock); in cyber2000fb_i2c_setsda()
1265 spin_unlock(&cfb->reg_b0_lock); in cyber2000fb_i2c_setsda()
1273 spin_lock(&cfb->reg_b0_lock); in cyber2000fb_i2c_setscl()
1279 spin_unlock(&cfb->reg_b0_lock); in cyber2000fb_i2c_setscl()
1287 spin_lock(&cfb->reg_b0_lock); in cyber2000fb_i2c_getsda()
1289 spin_unlock(&cfb->reg_b0_lock); in cyber2000fb_i2c_getsda()
1299 spin_lock(&cfb->reg_b0_lock); in cyber2000fb_i2c_getscl()
1301 spin_unlock(&cfb->reg_b0_lock); in cyber2000fb_i2c_getscl()
1308 strscpy(cfb->i2c_adapter.name, cfb->fb.fix.id, in cyber2000fb_i2c_register()
1309 sizeof(cfb->i2c_adapter.name)); in cyber2000fb_i2c_register()
1310 cfb->i2c_adapter.owner = THIS_MODULE; in cyber2000fb_i2c_register()
1311 cfb->i2c_adapter.algo_data = &cfb->i2c_algo; in cyber2000fb_i2c_register()
1312 cfb->i2c_adapter.dev.parent = cfb->fb.device; in cyber2000fb_i2c_register()
1313 cfb->i2c_algo.setsda = cyber2000fb_i2c_setsda; in cyber2000fb_i2c_register()
1314 cfb->i2c_algo.setscl = cyber2000fb_i2c_setscl; in cyber2000fb_i2c_register()
1315 cfb->i2c_algo.getsda = cyber2000fb_i2c_getsda; in cyber2000fb_i2c_register()
1316 cfb->i2c_algo.getscl = cyber2000fb_i2c_getscl; in cyber2000fb_i2c_register()
1317 cfb->i2c_algo.udelay = 5; in cyber2000fb_i2c_register()
1318 cfb->i2c_algo.timeout = msecs_to_jiffies(100); in cyber2000fb_i2c_register()
1319 cfb->i2c_algo.data = cfb; in cyber2000fb_i2c_register()
1321 return i2c_bit_add_bus(&cfb->i2c_adapter); in cyber2000fb_i2c_register()
1326 i2c_del_adapter(&cfb->i2c_adapter); in cyber2000fb_i2c_unregister()
1348 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
1386 * Initialise the CyberPro hardware. On the CyberPro5XXXX,
1397 if (cfb->id == ID_CYBERPRO_5000) { in cyberpro_init_hw()
1414 cfb->id = id; in cyberpro_alloc_fb_info()
1417 cfb->ref_ps = 40690; /* 24.576 MHz */ in cyberpro_alloc_fb_info()
1419 cfb->ref_ps = 69842; /* 14.31818 MHz (69841?) */ in cyberpro_alloc_fb_info()
1421 cfb->divisors[0] = 1; in cyberpro_alloc_fb_info()
1422 cfb->divisors[1] = 2; in cyberpro_alloc_fb_info()
1423 cfb->divisors[2] = 4; in cyberpro_alloc_fb_info()
1426 cfb->divisors[3] = 8; in cyberpro_alloc_fb_info()
1428 cfb->divisors[3] = 6; in cyberpro_alloc_fb_info()
1430 strcpy(cfb->fb.fix.id, name); in cyberpro_alloc_fb_info()
1432 cfb->fb.fix.type = FB_TYPE_PACKED_PIXELS; in cyberpro_alloc_fb_info()
1433 cfb->fb.fix.type_aux = 0; in cyberpro_alloc_fb_info()
1434 cfb->fb.fix.xpanstep = 0; in cyberpro_alloc_fb_info()
1435 cfb->fb.fix.ypanstep = 1; in cyberpro_alloc_fb_info()
1436 cfb->fb.fix.ywrapstep = 0; in cyberpro_alloc_fb_info()
1440 cfb->fb.fix.accel = 0; in cyberpro_alloc_fb_info()
1444 cfb->fb.fix.accel = FB_ACCEL_IGS_CYBER2000; in cyberpro_alloc_fb_info()
1448 cfb->fb.fix.accel = FB_ACCEL_IGS_CYBER2010; in cyberpro_alloc_fb_info()
1452 cfb->fb.fix.accel = FB_ACCEL_IGS_CYBER5000; in cyberpro_alloc_fb_info()
1456 cfb->fb.var.nonstd = 0; in cyberpro_alloc_fb_info()
1457 cfb->fb.var.activate = FB_ACTIVATE_NOW; in cyberpro_alloc_fb_info()
1458 cfb->fb.var.height = -1; in cyberpro_alloc_fb_info()
1459 cfb->fb.var.width = -1; in cyberpro_alloc_fb_info()
1460 cfb->fb.var.accel_flags = FB_ACCELF_TEXT; in cyberpro_alloc_fb_info()
1462 cfb->fb.fbops = &cyber2000fb_ops; in cyberpro_alloc_fb_info()
1463 cfb->fb.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; in cyberpro_alloc_fb_info()
1464 cfb->fb.pseudo_palette = cfb->pseudo_palette; in cyberpro_alloc_fb_info()
1466 spin_lock_init(&cfb->reg_b0_lock); in cyberpro_alloc_fb_info()
1468 fb_alloc_cmap(&cfb->fb.cmap, NR_PALETTE, 0); in cyberpro_alloc_fb_info()
1479 fb_alloc_cmap(&cfb->fb.cmap, 0, 0); in cyberpro_free_fb_info()
1517 * The CyberPro chips can be placed on many different bus types.
1518 * This probe function is common to all bus types. The bus-specific
1520 * - enabled access to the linear memory region
1521 * - memory mapped access to the registers
1522 * - initialised mem_ctl1 and mem_ctl2 appropriately.
1537 cfb->mem_ctl1 = cyber2000_grphr(EXT_MEM_CTL1, cfb); in cyberpro_common_probe()
1538 cfb->mem_ctl2 = cyber2000_grphr(EXT_MEM_CTL2, cfb); in cyberpro_common_probe()
1543 switch (cfb->mem_ctl2 & MEM_CTL2_SIZE_MASK) { in cyberpro_common_probe()
1558 cfb->fb.fix.smem_len = smem_size; in cyberpro_common_probe()
1559 cfb->fb.fix.mmio_len = MMIO_SIZE; in cyberpro_common_probe()
1560 cfb->fb.screen_base = cfb->region; in cyberpro_common_probe()
1564 cfb->ddc_registered = true; in cyberpro_common_probe()
1567 err = -EINVAL; in cyberpro_common_probe()
1568 if (!fb_find_mode(&cfb->fb.var, &cfb->fb, NULL, NULL, 0, in cyberpro_common_probe()
1570 printk(KERN_ERR "%s: no valid mode found\n", cfb->fb.fix.id); in cyberpro_common_probe()
1574 cfb->fb.var.yres_virtual = cfb->fb.fix.smem_len * 8 / in cyberpro_common_probe()
1575 (cfb->fb.var.bits_per_pixel * cfb->fb.var.xres_virtual); in cyberpro_common_probe()
1577 if (cfb->fb.var.yres_virtual < cfb->fb.var.yres) in cyberpro_common_probe()
1578 cfb->fb.var.yres_virtual = cfb->fb.var.yres; in cyberpro_common_probe()
1580 /* fb_set_var(&cfb->fb.var, -1, &cfb->fb); */ in cyberpro_common_probe()
1585 * the precision and fit the results into 32-bit registers. in cyberpro_common_probe()
1588 h_sync = 1953125000 / cfb->fb.var.pixclock; in cyberpro_common_probe()
1589 h_sync = h_sync * 512 / (cfb->fb.var.xres + cfb->fb.var.left_margin + in cyberpro_common_probe()
1590 cfb->fb.var.right_margin + cfb->fb.var.hsync_len); in cyberpro_common_probe()
1591 v_sync = h_sync / (cfb->fb.var.yres + cfb->fb.var.upper_margin + in cyberpro_common_probe()
1592 cfb->fb.var.lower_margin + cfb->fb.var.vsync_len); in cyberpro_common_probe()
1595 cfb->fb.fix.id, cfb->fb.fix.smem_len >> 10, in cyberpro_common_probe()
1596 cfb->fb.var.xres, cfb->fb.var.yres, in cyberpro_common_probe()
1603 err = register_framebuffer(&cfb->fb); in cyberpro_common_probe()
1609 if (err && cfb->ddc_registered) in cyberpro_common_probe()
1610 i2c_del_adapter(&cfb->ddc_adapter); in cyberpro_common_probe()
1617 unregister_framebuffer(&cfb->fb); in cyberpro_common_remove()
1619 if (cfb->ddc_registered) in cyberpro_common_remove()
1620 i2c_del_adapter(&cfb->ddc_adapter); in cyberpro_common_remove()
1632 cyber2000_grphw(EXT_MEM_CTL1, cfb->mem_ctl1, cfb); in cyberpro_common_resume()
1633 cyber2000_grphw(EXT_MEM_CTL2, cfb->mem_ctl2, cfb); in cyberpro_common_resume()
1639 cyber2000fb_set_par(&cfb->fb); in cyberpro_common_resume()
1645 * we are running on.
1647 * On x86 and ARM, should we be initialising the CyberPro first via the
1650 * on an x86 system?
1669 return -ENOMEM; in cyberpro_pci_enable_mmio()
1682 * we use the standard IO-based wakeup. in cyberpro_pci_enable_mmio()
1694 if (cfb->id == ID_CYBERPRO_2010) { in cyberpro_pci_enable_mmio()
1696 cfb->fb.fix.id); in cyberpro_pci_enable_mmio()
1701 cfb->fb.fix.id); in cyberpro_pci_enable_mmio()
1705 if (cfb->id == ID_CYBERPRO_5000) in cyberpro_pci_enable_mmio()
1722 sprintf(name, "CyberPro%4X", id->device); in cyberpro_pci_probe()
1732 err = -ENOMEM; in cyberpro_pci_probe()
1733 cfb = cyberpro_alloc_fb_info(id->driver_data, name); in cyberpro_pci_probe()
1737 err = pci_request_regions(dev, cfb->fb.fix.id); in cyberpro_pci_probe()
1741 cfb->irq = dev->irq; in cyberpro_pci_probe()
1742 cfb->region = pci_ioremap_bar(dev, 0); in cyberpro_pci_probe()
1743 if (!cfb->region) { in cyberpro_pci_probe()
1744 err = -ENOMEM; in cyberpro_pci_probe()
1748 cfb->regs = cfb->region + MMIO_OFFSET; in cyberpro_pci_probe()
1749 cfb->fb.device = &dev->dev; in cyberpro_pci_probe()
1750 cfb->fb.fix.mmio_start = pci_resource_start(dev, 0) + MMIO_OFFSET; in cyberpro_pci_probe()
1751 cfb->fb.fix.smem_start = pci_resource_start(dev, 0); in cyberpro_pci_probe()
1766 cfb->mclk_mult = cyber2000_grphr(EXT_MCLK_MULT, cfb); in cyberpro_pci_probe()
1767 cfb->mclk_div = cyber2000_grphr(EXT_MCLK_DIV, cfb); in cyberpro_pci_probe()
1771 * MCLK on the NetWinder and the Shark is fixed at 75MHz in cyberpro_pci_probe()
1774 cfb->mclk_mult = 0xdb; in cyberpro_pci_probe()
1775 cfb->mclk_div = 0x54; in cyberpro_pci_probe()
1793 iounmap(cfb->region); in cyberpro_pci_probe()
1809 iounmap(cfb->region); in cyberpro_pci_remove()
1826 * Re-initialise the CyberPro hardware
1877 int ret = -1, err; in cyber2000fb_init()
1883 return -ENODEV; in cyber2000fb_init()