Lines Matching +full:clip +full:- +full:y +full:- +full:low

2  * linux/drivers/video/atafb.c -- Atari builtin chipset frame buffer device
11 * - 03 Jan 95: Original version by Martin Schaller: The TT driver and
13 * - 09 Jan 95: Roman: I've added the hardware abstraction (hw_switch)
16 * - 07 May 95: Martin: Added colormap operations for the external driver
17 * - 21 May 95: Martin: Added support for overscan
19 * - Jul 95: Guenther Kelleter <guenther@pool.informatik.rwth-aachen.de>:
23 * - 27 Dec 95: Guenther: Implemented user definable video modes "user[0-7]"
25 * "R<x>;<y>;<depth>". (Makes sense only on Falcon)
28 * - 23 Sep 97: Juergen: added xres_virtual for cards like ProMST
29 * The external-part is legacy, therefore hardware-specific
32 * - 29 Sep 97: Juergen: added Romans suggestion for pan_display
33 * (var->xoffset was changed even if no set_screen_base avail.)
34 * - 05 Oct 97: Juergen: extfb (PACKED_PIXEL) is FB_PSEUDOCOLOR 'cause
40 * - For the Falcon it is not possible to set random video modes on
84 static int hwscroll = -1;
187 * not needed - atafb will never support panning/hardwarescroll with external
255 * * set the video mode according to info->var *
341 * succeeded, !=0 if un-/blanking failed due to e.g. a video mode which
396 * yres_virtual == 0 means use hw-scrolling if possible, else yres
399 0, 0, 0, 0, 0, 0, 0, 0, /* xres-grayscale */
401 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
402 { /* st low */
405 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
409 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
413 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
414 { /* tt low */
417 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
421 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
425 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
429 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
433 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
437 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
441 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
445 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
449 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
466 /* 320x200, 15 kHz, 60 Hz (ST low) */
467 "st-low", 60, 320, 200, 32000, 32, 16, 31, 14, 96, 4,
471 "st-mid", 60, 640, 200, 32000, 32, 16, 31, 14, 96, 4,
475 "st-high", 63, 640, 400, 32000, 128, 0, 40, 14, 128, 4,
478 /* 320x480, 15 kHz, 60 Hz (TT low) */
479 "tt-low", 60, 320, 480, 31041, 120, 100, 8, 16, 140, 30,
483 "tt-mid", 60, 640, 480, 31041, 120, 100, 8, 16, 140, 30,
487 "tt-high", 72, 1280, 960, 7760, 260, 60, 36, 4, 192, 4,
522 #define DEFMODE_TT 5 /* "tt-high" for TT */
524 #define DEFMODE_STE 2 /* "st-high" for ST/E */
550 /* ------------------- TT specific functions ---------------------- */
558 strcpy(fix->id, "Atari Builtin"); in tt_encode_fix()
559 fix->smem_start = phys_screen_base; in tt_encode_fix()
560 fix->smem_len = screen_len; in tt_encode_fix()
561 fix->type = FB_TYPE_INTERLEAVED_PLANES; in tt_encode_fix()
562 fix->type_aux = 2; in tt_encode_fix()
563 fix->visual = FB_VISUAL_PSEUDOCOLOR; in tt_encode_fix()
564 mode = par->hw.tt.mode & TT_SHIFTER_MODEMASK; in tt_encode_fix()
566 fix->type = FB_TYPE_PACKED_PIXELS; in tt_encode_fix()
567 fix->type_aux = 0; in tt_encode_fix()
569 fix->visual = FB_VISUAL_MONO01; in tt_encode_fix()
571 fix->xpanstep = 0; in tt_encode_fix()
572 fix->ypanstep = 1; in tt_encode_fix()
573 fix->ywrapstep = 0; in tt_encode_fix()
574 fix->line_length = par->next_line; in tt_encode_fix()
575 fix->accel = FB_ACCEL_ATARIBLITT; in tt_encode_fix()
581 int xres = var->xres; in tt_decode_var()
582 int yres = var->yres; in tt_decode_var()
583 int bpp = var->bits_per_pixel; in tt_decode_var()
585 int yres_virtual = var->yres_virtual; in tt_decode_var()
589 return -EINVAL; in tt_decode_var()
590 par->hw.tt.mode = TT_SHIFTER_TTHIGH; in tt_decode_var()
596 return -EINVAL; in tt_decode_var()
599 return -EINVAL; in tt_decode_var()
600 par->hw.tt.mode = TT_SHIFTER_TTLOW; in tt_decode_var()
606 return -EINVAL; in tt_decode_var()
608 par->hw.tt.mode = TT_SHIFTER_TTMID; in tt_decode_var()
613 par->hw.tt.mode = TT_SHIFTER_STLOW; in tt_decode_var()
620 return -EINVAL; in tt_decode_var()
621 par->hw.tt.mode = TT_SHIFTER_STMID; in tt_decode_var()
625 } else if (var->xres > sttt_xres || var->yres > st_yres) { in tt_decode_var()
626 return -EINVAL; in tt_decode_var()
628 par->hw.tt.mode = TT_SHIFTER_STHIGH; in tt_decode_var()
638 if (var->sync & FB_SYNC_EXT) in tt_decode_var()
639 par->hw.tt.sync = 0; in tt_decode_var()
641 par->hw.tt.sync = 1; in tt_decode_var()
644 return -EINVAL; in tt_decode_var()
646 return -EINVAL; in tt_decode_var()
647 if (var->yoffset + yres > yres_virtual && yres_virtual) in tt_decode_var()
648 return -EINVAL; in tt_decode_var()
649 par->yres_virtual = yres_virtual; in tt_decode_var()
650 par->screen_base = screen_base + var->yoffset * linelen; in tt_decode_var()
651 par->next_line = linelen; in tt_decode_var()
659 var->red.offset = 0; in tt_encode_var()
660 var->red.length = 4; in tt_encode_var()
661 var->red.msb_right = 0; in tt_encode_var()
662 var->grayscale = 0; in tt_encode_var()
664 var->pixclock = 31041; in tt_encode_var()
665 var->left_margin = 120; /* these may be incorrect */ in tt_encode_var()
666 var->right_margin = 100; in tt_encode_var()
667 var->upper_margin = 8; in tt_encode_var()
668 var->lower_margin = 16; in tt_encode_var()
669 var->hsync_len = 140; in tt_encode_var()
670 var->vsync_len = 30; in tt_encode_var()
672 var->height = -1; in tt_encode_var()
673 var->width = -1; in tt_encode_var()
675 if (par->hw.tt.sync & 1) in tt_encode_var()
676 var->sync = 0; in tt_encode_var()
678 var->sync = FB_SYNC_EXT; in tt_encode_var()
680 switch (par->hw.tt.mode & TT_SHIFTER_MODEMASK) { in tt_encode_var()
682 var->xres = sttt_xres / 2; in tt_encode_var()
683 var->xres_virtual = sttt_xres_virtual / 2; in tt_encode_var()
684 var->yres = st_yres / 2; in tt_encode_var()
685 var->bits_per_pixel = 4; in tt_encode_var()
688 var->xres = sttt_xres; in tt_encode_var()
689 var->xres_virtual = sttt_xres_virtual; in tt_encode_var()
690 var->yres = st_yres / 2; in tt_encode_var()
691 var->bits_per_pixel = 2; in tt_encode_var()
694 var->xres = sttt_xres; in tt_encode_var()
695 var->xres_virtual = sttt_xres_virtual; in tt_encode_var()
696 var->yres = st_yres; in tt_encode_var()
697 var->bits_per_pixel = 1; in tt_encode_var()
700 var->xres = sttt_xres / 2; in tt_encode_var()
701 var->xres_virtual = sttt_xres_virtual / 2; in tt_encode_var()
702 var->yres = tt_yres; in tt_encode_var()
703 var->bits_per_pixel = 8; in tt_encode_var()
706 var->xres = sttt_xres; in tt_encode_var()
707 var->xres_virtual = sttt_xres_virtual; in tt_encode_var()
708 var->yres = tt_yres; in tt_encode_var()
709 var->bits_per_pixel = 4; in tt_encode_var()
712 var->red.length = 0; in tt_encode_var()
713 var->xres = sttt_xres * 2; in tt_encode_var()
714 var->xres_virtual = sttt_xres_virtual * 2; in tt_encode_var()
715 var->yres = tt_yres * 2; in tt_encode_var()
716 var->bits_per_pixel = 1; in tt_encode_var()
719 var->blue = var->green = var->red; in tt_encode_var()
720 var->transp.offset = 0; in tt_encode_var()
721 var->transp.length = 0; in tt_encode_var()
722 var->transp.msb_right = 0; in tt_encode_var()
723 linelen = var->xres_virtual * var->bits_per_pixel / 8; in tt_encode_var()
725 var->yres_virtual = var->yres; in tt_encode_var()
727 if (par->yres_virtual) in tt_encode_var()
728 var->yres_virtual = par->yres_virtual; in tt_encode_var()
731 var->yres_virtual = screen_len / linelen; in tt_encode_var()
734 var->yres_virtual = 2 * var->yres; in tt_encode_var()
736 var->yres_virtual = var->yres + hwscroll * 16; in tt_encode_var()
738 var->xoffset = 0; in tt_encode_var()
740 var->yoffset = (par->screen_base - screen_base) / linelen; in tt_encode_var()
742 var->yoffset = 0; in tt_encode_var()
743 var->nonstd = 0; in tt_encode_var()
744 var->activate = 0; in tt_encode_var()
745 var->vmode = FB_VMODE_NONINTERLACED; in tt_encode_var()
752 par->hw.tt.mode = shifter_tt.tt_shiftmode; in tt_get_par()
753 par->hw.tt.sync = shifter_st.syncmode; in tt_get_par()
757 par->screen_base = atari_stram_to_virt(addr); in tt_get_par()
762 shifter_tt.tt_shiftmode = par->hw.tt.mode; in tt_set_par()
763 shifter_st.syncmode = par->hw.tt.sync; in tt_set_par()
765 if (current_par.screen_base != par->screen_base) in tt_set_par()
766 fbhw->set_screen_base(par->screen_base); in tt_set_par()
811 /* ------------------- Falcon specific functions ---------------------- */
827 int sync_mask; /* or-mask for hw.falcon.sync to set this clock */
837 /* VIDEL-prescale values [mon_type][pixel_length from VCO] */
847 return hw->ste_mode ? 16 in hxx_prescale()
848 : vdl_prescale[mon_type][hw->vid_mode >> 2 & 0x3]; in hxx_prescale()
854 strcpy(fix->id, "Atari Builtin"); in falcon_encode_fix()
855 fix->smem_start = phys_screen_base; in falcon_encode_fix()
856 fix->smem_len = screen_len; in falcon_encode_fix()
857 fix->type = FB_TYPE_INTERLEAVED_PLANES; in falcon_encode_fix()
858 fix->type_aux = 2; in falcon_encode_fix()
859 fix->visual = FB_VISUAL_PSEUDOCOLOR; in falcon_encode_fix()
860 fix->xpanstep = 1; in falcon_encode_fix()
861 fix->ypanstep = 1; in falcon_encode_fix()
862 fix->ywrapstep = 0; in falcon_encode_fix()
863 if (par->hw.falcon.mono) { in falcon_encode_fix()
864 fix->type = FB_TYPE_PACKED_PIXELS; in falcon_encode_fix()
865 fix->type_aux = 0; in falcon_encode_fix()
867 fix->xpanstep = 32; in falcon_encode_fix()
868 } else if (par->hw.falcon.f_shift & 0x100) { in falcon_encode_fix()
869 fix->type = FB_TYPE_PACKED_PIXELS; in falcon_encode_fix()
870 fix->type_aux = 0; in falcon_encode_fix()
872 fix->visual = FB_VISUAL_TRUECOLOR; in falcon_encode_fix()
873 fix->xpanstep = 2; in falcon_encode_fix()
875 fix->line_length = par->next_line; in falcon_encode_fix()
876 fix->accel = FB_ACCEL_ATARIBLITT; in falcon_encode_fix()
883 int bpp = var->bits_per_pixel; in falcon_decode_var()
884 int xres = var->xres; in falcon_decode_var()
885 int yres = var->yres; in falcon_decode_var()
886 int xres_virtual = var->xres_virtual; in falcon_decode_var()
887 int yres_virtual = var->yres_virtual; in falcon_decode_var()
909 and minimum frame rate -- (X+hmarg.)*(Y+vmarg.)*vfmin <= pixelclock. in falcon_decode_var()
916 Y % 16 == 0 to fit 8x16 font in falcon_decode_var()
917 Y % 8 == 0 if Y<400 in falcon_decode_var()
925 return -EINVAL; in falcon_decode_var()
928 return -EINVAL; in falcon_decode_var()
932 par->hw.falcon.f_shift = 0x400; in falcon_decode_var()
933 par->hw.falcon.st_shift = 0x200; in falcon_decode_var()
936 par->hw.falcon.f_shift = 0x000; in falcon_decode_var()
937 par->hw.falcon.st_shift = 0x100; in falcon_decode_var()
940 par->hw.falcon.f_shift = 0x000; in falcon_decode_var()
941 par->hw.falcon.st_shift = 0x000; in falcon_decode_var()
944 par->hw.falcon.f_shift = 0x010; in falcon_decode_var()
947 par->hw.falcon.f_shift = 0x100; /* hicolor, no overlay */ in falcon_decode_var()
949 return -EINVAL; in falcon_decode_var()
950 par->hw.falcon.bpp = bpp; in falcon_decode_var()
956 if (bpp > myvar->bits_per_pixel || in falcon_decode_var()
957 var->xres > myvar->xres || in falcon_decode_var()
958 var->yres > myvar->yres) in falcon_decode_var()
959 return -EINVAL; in falcon_decode_var()
960 fbhw->get_par(par); /* Current par will be new par */ in falcon_decode_var()
977 par->hw.falcon.ste_mode = bpp == 2; in falcon_decode_var()
978 par->hw.falcon.mono = bpp == 1; in falcon_decode_var()
988 if (par->hw.falcon.ste_mode) in falcon_decode_var()
1011 par->hw.falcon.line_width = bpp * xres / 16; in falcon_decode_var()
1012 par->hw.falcon.line_offset = bpp * (xres_virtual - xres) / 16; in falcon_decode_var()
1020 return -EINVAL; in falcon_decode_var()
1023 /* SM124-mode is special */ in falcon_decode_var()
1024 par->hw.falcon.ste_mode = 1; in falcon_decode_var()
1025 par->hw.falcon.f_shift = 0x000; in falcon_decode_var()
1026 par->hw.falcon.st_shift = 0x200; in falcon_decode_var()
1034 if (var->pixclock > f32.t * plen) in falcon_decode_var()
1035 return -EINVAL; in falcon_decode_var()
1039 if (var->pixclock == 0) { in falcon_decode_var()
1043 hsync_len = pclock->hsync / plen; in falcon_decode_var()
1048 left_margin = var->left_margin; in falcon_decode_var()
1049 right_margin = var->right_margin; in falcon_decode_var()
1050 hsync_len = var->hsync_len; in falcon_decode_var()
1051 upper_margin = var->upper_margin; in falcon_decode_var()
1052 lower_margin = var->lower_margin; in falcon_decode_var()
1053 vsync_len = var->vsync_len; in falcon_decode_var()
1054 if (var->vmode & FB_VMODE_INTERLACED) { in falcon_decode_var()
1058 } else if (var->vmode & FB_VMODE_DOUBLE) { in falcon_decode_var()
1068 if (var->pixclock == 0) { in falcon_decode_var()
1082 return -EINVAL; in falcon_decode_var()
1084 left_margin = pclock->left / plen; in falcon_decode_var()
1085 right_margin = pclock->right / plen; in falcon_decode_var()
1086 hsync_len = pclock->hsync / plen; in falcon_decode_var()
1096 if (f25.t * i >= var->pixclock && in falcon_decode_var()
1101 if (f32.t * i >= var->pixclock && in falcon_decode_var()
1106 if (fext.t && fext.t * i >= var->pixclock && in falcon_decode_var()
1113 return -EINVAL; in falcon_decode_var()
1114 plen = pcl / pclock->t; in falcon_decode_var()
1116 left_margin = var->left_margin; in falcon_decode_var()
1117 right_margin = var->right_margin; in falcon_decode_var()
1118 hsync_len = var->hsync_len; in falcon_decode_var()
1119 upper_margin = var->upper_margin; in falcon_decode_var()
1120 lower_margin = var->lower_margin; in falcon_decode_var()
1121 vsync_len = var->vsync_len; in falcon_decode_var()
1122 /* Internal unit is [single lines per (half-)frame] */ in falcon_decode_var()
1123 if (var->vmode & FB_VMODE_INTERLACED) { in falcon_decode_var()
1129 } else if (var->vmode & FB_VMODE_DOUBLE) { in falcon_decode_var()
1139 /* Is video bus bandwidth (32MB/s) too low for this resolution? */ in falcon_decode_var()
1141 if (pclock->f / plen / 8 * bpp > 32000000L) in falcon_decode_var()
1142 return -EINVAL; in falcon_decode_var()
1152 * (which is a full frame in non-interlace mode), so we can switch in falcon_decode_var()
1153 * between interlace and non-interlace without messing around in falcon_decode_var()
1158 par->hw.falcon.vid_control = mon_type | f030_bus_width; in falcon_decode_var()
1160 par->hw.falcon.vid_control |= VCO_SHORTOFFS; /* base_offset 64 */ in falcon_decode_var()
1161 if (var->sync & FB_SYNC_HOR_HIGH_ACT) in falcon_decode_var()
1162 par->hw.falcon.vid_control |= VCO_HSYPOS; in falcon_decode_var()
1163 if (var->sync & FB_SYNC_VERT_HIGH_ACT) in falcon_decode_var()
1164 par->hw.falcon.vid_control |= VCO_VSYPOS; in falcon_decode_var()
1166 par->hw.falcon.vid_control |= pclock->control_mask; in falcon_decode_var()
1168 par->hw.falcon.sync = pclock->sync_mask | 0x2; in falcon_decode_var()
1170 par->hw.falcon.vid_mode = (2 / plen) << 2; in falcon_decode_var()
1172 par->hw.falcon.vid_mode |= VMO_DOUBLE; in falcon_decode_var()
1174 par->hw.falcon.vid_mode |= VMO_INTER; in falcon_decode_var()
1178 * unit of hxx-registers: [master clock cycles * prescale] in falcon_decode_var()
1179 * Hxx-registers are 9 bit wide in falcon_decode_var()
1184 * ((hht + 2) * 2 - hdb + hde) * prescale - hdboff + hdeoff: in falcon_decode_var()
1185 * (hht + 2 - hdb + hde) * prescale - hdboff + hdeoff in falcon_decode_var()
1190 * (hdb - hht - 2) * prescale + hdboff : in falcon_decode_var()
1198 prescale = hxx_prescale(&par->hw.falcon); in falcon_decode_var()
1199 base_off = par->hw.falcon.vid_control & VCO_SHORTOFFS ? 64 : 128; in falcon_decode_var()
1203 * calculate hd[be]-registers in falcon_decode_var()
1205 if (par->hw.falcon.f_shift & 0x100) { in falcon_decode_var()
1212 if (par->hw.falcon.ste_mode) in falcon_decode_var()
1219 /* gend1 is for hde (gend-gstart multiple of align), shifter's xres */ in falcon_decode_var()
1223 par->HHT = plen * (left_margin + xres + right_margin) / in falcon_decode_var()
1224 (2 * prescale) - 2; in falcon_decode_var()
1225 /* par->HHT = (gend2 + plen * right_margin / prescale) / 2 - 2;*/ in falcon_decode_var()
1227 par->HDB = gstart - hdb_off / prescale; in falcon_decode_var()
1228 par->HBE = gstart; in falcon_decode_var()
1229 if (par->HDB < 0) in falcon_decode_var()
1230 par->HDB += par->HHT + 2 + 0x200; in falcon_decode_var()
1231 par->HDE = gend1 - par->HHT - 2 - hde_off / prescale; in falcon_decode_var()
1232 par->HBB = gend2 - par->HHT - 2; in falcon_decode_var()
1235 if ((par->HDB & 0x200) && (par->HDB & ~0x200) - par->HDE <= 5) { in falcon_decode_var()
1240 par->HBB++; /* compensate for non matching hde and hbb */ in falcon_decode_var()
1241 par->HSS = par->HHT + 2 - plen * hsync_len / prescale; in falcon_decode_var()
1242 if (par->HSS < par->HBB) in falcon_decode_var()
1243 par->HSS = par->HBB; in falcon_decode_var()
1247 hfreq = pclock->f / ((par->HHT + 2) * prescale * 2); in falcon_decode_var()
1250 /* Too high -> enlarge margin */ in falcon_decode_var()
1256 return -EINVAL; in falcon_decode_var()
1258 /* Vxx-registers */ in falcon_decode_var()
1259 /* All Vxx must be odd in non-interlace, since frame starts in the middle in falcon_decode_var()
1262 * non-interlace, odd in interlace mode for synchronisation. in falcon_decode_var()
1263 * Vxx-registers are 11 bit wide in falcon_decode_var()
1265 par->VBE = (upper_margin * 2 + 1); /* must begin on odd halfline */ in falcon_decode_var()
1266 par->VDB = par->VBE; in falcon_decode_var()
1267 par->VDE = yres; in falcon_decode_var()
1269 par->VDE <<= 1; in falcon_decode_var()
1271 par->VDE <<= 1; /* VDE now half lines per (half-)frame */ in falcon_decode_var()
1272 par->VDE += par->VDB; in falcon_decode_var()
1273 par->VBB = par->VDE; in falcon_decode_var()
1274 par->VFT = par->VBB + (lower_margin * 2 - 1) - 1; in falcon_decode_var()
1275 par->VSS = par->VFT + 1 - (vsync_len * 2 - 1); in falcon_decode_var()
1278 par->VBB++; in falcon_decode_var()
1279 par->VSS++; in falcon_decode_var()
1280 par->VFT++; in falcon_decode_var()
1283 /* V-frequency check, hope I didn't create any loop here. */ in falcon_decode_var()
1285 vfreq = (hfreq * 2) / (par->VFT + 1); in falcon_decode_var()
1287 /* Too high -> try again with doubleline */ in falcon_decode_var()
1291 /* Too low -> try again with interlace */ in falcon_decode_var()
1295 /* Doubleline too low -> clear doubleline and enlarge margins */ in falcon_decode_var()
1299 (hfreq * 2) / (par->VFT + 1 + 4 * lines - 2 * yres) > in falcon_decode_var()
1307 /* Doubleline too high -> enlarge margins */ in falcon_decode_var()
1310 (hfreq * 2) / (par->VFT + 1 + 4 * lines) > in falcon_decode_var()
1318 /* Interlace, too high -> enlarge margins */ in falcon_decode_var()
1321 (hfreq * 2) / (par->VFT + 1 + 4 * lines) > in falcon_decode_var()
1330 return -EINVAL; in falcon_decode_var()
1335 return -EINVAL; in falcon_decode_var()
1337 return -EINVAL; in falcon_decode_var()
1338 if (var->yoffset + yres > yres_virtual && yres_virtual) in falcon_decode_var()
1339 return -EINVAL; in falcon_decode_var()
1340 par->yres_virtual = yres_virtual; in falcon_decode_var()
1341 par->screen_base = screen_base + var->yoffset * linelen; in falcon_decode_var()
1342 par->hw.falcon.xoffset = 0; in falcon_decode_var()
1344 par->next_line = linelen; in falcon_decode_var()
1356 struct falcon_hw *hw = &par->hw.falcon; in falcon_encode_var()
1360 var->pixclock = hw->sync & 0x1 ? fext.t : in falcon_encode_var()
1361 hw->vid_control & VCO_CLOCK25 ? f25.t : f32.t; in falcon_encode_var()
1363 var->height = -1; in falcon_encode_var()
1364 var->width = -1; in falcon_encode_var()
1366 var->sync = 0; in falcon_encode_var()
1367 if (hw->vid_control & VCO_HSYPOS) in falcon_encode_var()
1368 var->sync |= FB_SYNC_HOR_HIGH_ACT; in falcon_encode_var()
1369 if (hw->vid_control & VCO_VSYPOS) in falcon_encode_var()
1370 var->sync |= FB_SYNC_VERT_HIGH_ACT; in falcon_encode_var()
1372 var->vmode = FB_VMODE_NONINTERLACED; in falcon_encode_var()
1373 if (hw->vid_mode & VMO_INTER) in falcon_encode_var()
1374 var->vmode |= FB_VMODE_INTERLACED; in falcon_encode_var()
1375 if (hw->vid_mode & VMO_DOUBLE) in falcon_encode_var()
1376 var->vmode |= FB_VMODE_DOUBLE; in falcon_encode_var()
1378 /* visible y resolution: in falcon_encode_var()
1380 * VDE. If interlace mode off unit of VC-registers is in falcon_encode_var()
1383 var->yres = hw->vde - hw->vdb; in falcon_encode_var()
1384 if (!(var->vmode & FB_VMODE_INTERLACED)) in falcon_encode_var()
1385 var->yres >>= 1; in falcon_encode_var()
1386 if (var->vmode & FB_VMODE_DOUBLE) in falcon_encode_var()
1387 var->yres >>= 1; in falcon_encode_var()
1397 if (hw->f_shift & 0x400) /* 2 colors */ in falcon_encode_var()
1398 var->bits_per_pixel = 1; in falcon_encode_var()
1399 else if (hw->f_shift & 0x100) /* hicolor */ in falcon_encode_var()
1400 var->bits_per_pixel = 16; in falcon_encode_var()
1401 else if (hw->f_shift & 0x010) /* 8 bitplanes */ in falcon_encode_var()
1402 var->bits_per_pixel = 8; in falcon_encode_var()
1403 else if (hw->st_shift == 0) in falcon_encode_var()
1404 var->bits_per_pixel = 4; in falcon_encode_var()
1405 else if (hw->st_shift == 0x100) in falcon_encode_var()
1406 var->bits_per_pixel = 2; in falcon_encode_var()
1407 else /* if (hw->st_shift == 0x200) */ in falcon_encode_var()
1408 var->bits_per_pixel = 1; in falcon_encode_var()
1410 var->xres = hw->line_width * 16 / var->bits_per_pixel; in falcon_encode_var()
1411 var->xres_virtual = var->xres + hw->line_offset * 16 / var->bits_per_pixel; in falcon_encode_var()
1412 if (hw->xoffset) in falcon_encode_var()
1413 var->xres_virtual += 16; in falcon_encode_var()
1415 if (var->bits_per_pixel == 16) { in falcon_encode_var()
1416 var->red.offset = 11; in falcon_encode_var()
1417 var->red.length = 5; in falcon_encode_var()
1418 var->red.msb_right = 0; in falcon_encode_var()
1419 var->green.offset = 5; in falcon_encode_var()
1420 var->green.length = 6; in falcon_encode_var()
1421 var->green.msb_right = 0; in falcon_encode_var()
1422 var->blue.offset = 0; in falcon_encode_var()
1423 var->blue.length = 5; in falcon_encode_var()
1424 var->blue.msb_right = 0; in falcon_encode_var()
1426 var->red.offset = 0; in falcon_encode_var()
1427 var->red.length = hw->ste_mode ? 4 : 6; in falcon_encode_var()
1428 if (var->red.length > var->bits_per_pixel) in falcon_encode_var()
1429 var->red.length = var->bits_per_pixel; in falcon_encode_var()
1430 var->red.msb_right = 0; in falcon_encode_var()
1431 var->grayscale = 0; in falcon_encode_var()
1432 var->blue = var->green = var->red; in falcon_encode_var()
1434 var->transp.offset = 0; in falcon_encode_var()
1435 var->transp.length = 0; in falcon_encode_var()
1436 var->transp.msb_right = 0; in falcon_encode_var()
1438 linelen = var->xres_virtual * var->bits_per_pixel / 8; in falcon_encode_var()
1440 if (par->yres_virtual) in falcon_encode_var()
1441 var->yres_virtual = par->yres_virtual; in falcon_encode_var()
1444 var->yres_virtual = screen_len / linelen; in falcon_encode_var()
1447 var->yres_virtual = 2 * var->yres; in falcon_encode_var()
1449 var->yres_virtual = var->yres + hwscroll * 16; in falcon_encode_var()
1451 var->xoffset = 0; /* TODO change this */ in falcon_encode_var()
1453 /* hdX-offsets */ in falcon_encode_var()
1455 plen = 4 >> (hw->vid_mode >> 2 & 0x3); in falcon_encode_var()
1456 base_off = hw->vid_control & VCO_SHORTOFFS ? 64 : 128; in falcon_encode_var()
1457 if (hw->f_shift & 0x100) { in falcon_encode_var()
1461 hde_off = ((128 / var->bits_per_pixel + 2) * plen); in falcon_encode_var()
1462 if (hw->ste_mode) in falcon_encode_var()
1463 hdb_off = (64 + base_off + (128 / var->bits_per_pixel + 2) * plen) in falcon_encode_var()
1466 hdb_off = (base_off + (128 / var->bits_per_pixel + 18) * plen) in falcon_encode_var()
1471 var->left_margin = hdb_off + prescale * ((hw->hdb & 0x1ff) - in falcon_encode_var()
1472 (hw->hdb & 0x200 ? 2 + hw->hht : 0)); in falcon_encode_var()
1473 if (hw->ste_mode || mon_type != F_MON_VGA) in falcon_encode_var()
1474 var->right_margin = prescale * (hw->hht + 2 - hw->hde) - hde_off; in falcon_encode_var()
1477 var->right_margin = prescale * (hw->hht + 2 - hw->hbb); in falcon_encode_var()
1478 var->hsync_len = prescale * (hw->hht + 2 - hw->hss); in falcon_encode_var()
1481 var->upper_margin = hw->vdb / 2; /* round down to full lines */ in falcon_encode_var()
1482 var->lower_margin = (hw->vft + 1 - hw->vde + 1) / 2; /* round up */ in falcon_encode_var()
1483 var->vsync_len = (hw->vft + 1 - hw->vss + 1) / 2; /* round up */ in falcon_encode_var()
1484 if (var->vmode & FB_VMODE_INTERLACED) { in falcon_encode_var()
1485 var->upper_margin *= 2; in falcon_encode_var()
1486 var->lower_margin *= 2; in falcon_encode_var()
1487 var->vsync_len *= 2; in falcon_encode_var()
1488 } else if (var->vmode & FB_VMODE_DOUBLE) { in falcon_encode_var()
1489 var->upper_margin = (var->upper_margin + 1) / 2; in falcon_encode_var()
1490 var->lower_margin = (var->lower_margin + 1) / 2; in falcon_encode_var()
1491 var->vsync_len = (var->vsync_len + 1) / 2; in falcon_encode_var()
1494 var->pixclock *= plen; in falcon_encode_var()
1495 var->left_margin /= plen; in falcon_encode_var()
1496 var->right_margin /= plen; in falcon_encode_var()
1497 var->hsync_len /= plen; in falcon_encode_var()
1499 var->right_margin -= var->hsync_len; in falcon_encode_var()
1500 var->lower_margin -= var->vsync_len; in falcon_encode_var()
1503 var->yoffset = (par->screen_base - screen_base) / linelen; in falcon_encode_var()
1505 var->yoffset = 0; in falcon_encode_var()
1506 var->nonstd = 0; /* what is this for? */ in falcon_encode_var()
1507 var->activate = 0; in falcon_encode_var()
1518 struct falcon_hw *hw = &par->hw.falcon; in falcon_get_par()
1520 hw->line_width = shifter_f030.scn_width; in falcon_get_par()
1521 hw->line_offset = shifter_f030.off_next; in falcon_get_par()
1522 hw->st_shift = videl.st_shift & 0x300; in falcon_get_par()
1523 hw->f_shift = videl.f_shift; in falcon_get_par()
1524 hw->vid_control = videl.control; in falcon_get_par()
1525 hw->vid_mode = videl.mode; in falcon_get_par()
1526 hw->sync = shifter_st.syncmode & 0x1; in falcon_get_par()
1527 hw->xoffset = videl.xoffset & 0xf; in falcon_get_par()
1528 hw->hht = videl.hht; in falcon_get_par()
1529 hw->hbb = videl.hbb; in falcon_get_par()
1530 hw->hbe = videl.hbe; in falcon_get_par()
1531 hw->hdb = videl.hdb; in falcon_get_par()
1532 hw->hde = videl.hde; in falcon_get_par()
1533 hw->hss = videl.hss; in falcon_get_par()
1534 hw->vft = videl.vft; in falcon_get_par()
1535 hw->vbb = videl.vbb; in falcon_get_par()
1536 hw->vbe = videl.vbe; in falcon_get_par()
1537 hw->vdb = videl.vdb; in falcon_get_par()
1538 hw->vde = videl.vde; in falcon_get_par()
1539 hw->vss = videl.vss; in falcon_get_par()
1544 par->screen_base = atari_stram_to_virt(addr); in falcon_get_par()
1547 hw->ste_mode = (hw->f_shift & 0x510) == 0 && hw->st_shift == 0x100; in falcon_get_par()
1548 hw->mono = (hw->f_shift & 0x400) || in falcon_get_par()
1549 ((hw->f_shift & 0x510) == 0 && hw->st_shift == 0x200); in falcon_get_par()
1557 if (current_par.screen_base != par->screen_base) in falcon_set_par()
1558 fbhw->set_screen_base(par->screen_base); in falcon_set_par()
1564 /* Tell vbl-handler to change video mode. in falcon_set_par()
1570 f_new_mode = par->hw.falcon; in falcon_set_par()
1581 if (hw->sync & 0x1) { in falcon_vbl_switcher()
1588 shifter_st.syncmode = hw->sync; in falcon_vbl_switcher()
1590 videl.hht = hw->hht; in falcon_vbl_switcher()
1591 videl.hbb = hw->hbb; in falcon_vbl_switcher()
1592 videl.hbe = hw->hbe; in falcon_vbl_switcher()
1593 videl.hdb = hw->hdb; in falcon_vbl_switcher()
1594 videl.hde = hw->hde; in falcon_vbl_switcher()
1595 videl.hss = hw->hss; in falcon_vbl_switcher()
1596 videl.vft = hw->vft; in falcon_vbl_switcher()
1597 videl.vbb = hw->vbb; in falcon_vbl_switcher()
1598 videl.vbe = hw->vbe; in falcon_vbl_switcher()
1599 videl.vdb = hw->vdb; in falcon_vbl_switcher()
1600 videl.vde = hw->vde; in falcon_vbl_switcher()
1601 videl.vss = hw->vss; in falcon_vbl_switcher()
1604 if (hw->ste_mode) { in falcon_vbl_switcher()
1605 videl.st_shift = hw->st_shift; /* write enables STE palette */ in falcon_vbl_switcher()
1608 * set st_shift 0, so we can tell the screen-depth if f_shift == 0. in falcon_vbl_switcher()
1615 videl.f_shift = hw->f_shift; in falcon_vbl_switcher()
1618 videl.xoffset = hw->xoffset; in falcon_vbl_switcher()
1619 shifter_f030.scn_width = hw->line_width; in falcon_vbl_switcher()
1620 shifter_f030.off_next = hw->line_offset; in falcon_vbl_switcher()
1621 videl.control = hw->vid_control; in falcon_vbl_switcher()
1622 videl.mode = hw->vid_mode; in falcon_vbl_switcher()
1635 struct atafb_par *par = info->par; in falcon_pan_display()
1638 int bpp = info->var.bits_per_pixel; in falcon_pan_display()
1641 var->xoffset = round_up(var->xoffset, 32); in falcon_pan_display()
1643 par->hw.falcon.xoffset = var->xoffset & 15; in falcon_pan_display()
1645 par->hw.falcon.xoffset = 0; in falcon_pan_display()
1646 var->xoffset = round_up(var->xoffset, 2); in falcon_pan_display()
1648 par->hw.falcon.line_offset = bpp * in falcon_pan_display()
1649 (info->var.xres_virtual - info->var.xres) / 16; in falcon_pan_display()
1650 if (par->hw.falcon.xoffset) in falcon_pan_display()
1651 par->hw.falcon.line_offset -= bpp; in falcon_pan_display()
1652 xoffset = var->xoffset - par->hw.falcon.xoffset; in falcon_pan_display()
1654 par->screen_base = screen_base + in falcon_pan_display()
1655 (var->yoffset * info->var.xres_virtual + xoffset) * bpp / 8; in falcon_pan_display()
1656 if (fbhw->set_screen_base) in falcon_pan_display()
1657 fbhw->set_screen_base(par->screen_base); in falcon_pan_display()
1659 return -EINVAL; /* shouldn't happen */ in falcon_pan_display()
1678 ((u32 *)info->pseudo_palette)[regno] = ((red & 0xf800) | in falcon_setcolreg()
1749 /* initialize hsync-len */ in falcon_detect()
1764 /* ------------------- ST(E) specific functions ---------------------- */
1773 strcpy(fix->id, "Atari Builtin"); in stste_encode_fix()
1774 fix->smem_start = phys_screen_base; in stste_encode_fix()
1775 fix->smem_len = screen_len; in stste_encode_fix()
1776 fix->type = FB_TYPE_INTERLEAVED_PLANES; in stste_encode_fix()
1777 fix->type_aux = 2; in stste_encode_fix()
1778 fix->visual = FB_VISUAL_PSEUDOCOLOR; in stste_encode_fix()
1779 mode = par->hw.st.mode & 3; in stste_encode_fix()
1781 fix->type = FB_TYPE_PACKED_PIXELS; in stste_encode_fix()
1782 fix->type_aux = 0; in stste_encode_fix()
1783 fix->visual = FB_VISUAL_MONO10; in stste_encode_fix()
1786 fix->xpanstep = 16; in stste_encode_fix()
1787 fix->ypanstep = 1; in stste_encode_fix()
1789 fix->xpanstep = 0; in stste_encode_fix()
1790 fix->ypanstep = 0; in stste_encode_fix()
1792 fix->ywrapstep = 0; in stste_encode_fix()
1793 fix->line_length = par->next_line; in stste_encode_fix()
1794 fix->accel = FB_ACCEL_ATARIBLITT; in stste_encode_fix()
1801 int xres = var->xres; in stste_decode_var()
1802 int yres = var->yres; in stste_decode_var()
1803 int bpp = var->bits_per_pixel; in stste_decode_var()
1805 int yres_virtual = var->yres_virtual; in stste_decode_var()
1809 return -EINVAL; in stste_decode_var()
1810 par->hw.st.mode = ST_HIGH; in stste_decode_var()
1816 return -EINVAL; in stste_decode_var()
1819 return -EINVAL; in stste_decode_var()
1820 par->hw.st.mode = ST_LOW; in stste_decode_var()
1826 return -EINVAL; in stste_decode_var()
1827 par->hw.st.mode = ST_MID; in stste_decode_var()
1832 return -EINVAL; in stste_decode_var()
1838 if (var->sync & FB_SYNC_EXT) in stste_decode_var()
1839 par->hw.st.sync = (par->hw.st.sync & ~1) | 1; in stste_decode_var()
1841 par->hw.st.sync = (par->hw.st.sync & ~1); in stste_decode_var()
1844 return -EINVAL; in stste_decode_var()
1846 return -EINVAL; in stste_decode_var()
1847 if (var->yoffset + yres > yres_virtual && yres_virtual) in stste_decode_var()
1848 return -EINVAL; in stste_decode_var()
1849 par->yres_virtual = yres_virtual; in stste_decode_var()
1850 par->screen_base = screen_base + var->yoffset * linelen; in stste_decode_var()
1851 par->next_line = linelen; in stste_decode_var()
1860 var->red.offset = 0; in stste_encode_var()
1861 var->red.length = ATARIHW_PRESENT(EXTD_SHIFTER) ? 4 : 3; in stste_encode_var()
1862 var->red.msb_right = 0; in stste_encode_var()
1863 var->grayscale = 0; in stste_encode_var()
1865 var->pixclock = 31041; in stste_encode_var()
1866 var->left_margin = 120; /* these are incorrect */ in stste_encode_var()
1867 var->right_margin = 100; in stste_encode_var()
1868 var->upper_margin = 8; in stste_encode_var()
1869 var->lower_margin = 16; in stste_encode_var()
1870 var->hsync_len = 140; in stste_encode_var()
1871 var->vsync_len = 30; in stste_encode_var()
1873 var->height = -1; in stste_encode_var()
1874 var->width = -1; in stste_encode_var()
1876 if (!(par->hw.st.sync & 1)) in stste_encode_var()
1877 var->sync = 0; in stste_encode_var()
1879 var->sync = FB_SYNC_EXT; in stste_encode_var()
1881 switch (par->hw.st.mode & 3) { in stste_encode_var()
1883 var->xres = sttt_xres / 2; in stste_encode_var()
1884 var->yres = st_yres / 2; in stste_encode_var()
1885 var->bits_per_pixel = 4; in stste_encode_var()
1888 var->xres = sttt_xres; in stste_encode_var()
1889 var->yres = st_yres / 2; in stste_encode_var()
1890 var->bits_per_pixel = 2; in stste_encode_var()
1893 var->xres = sttt_xres; in stste_encode_var()
1894 var->yres = st_yres; in stste_encode_var()
1895 var->bits_per_pixel = 1; in stste_encode_var()
1898 var->blue = var->green = var->red; in stste_encode_var()
1899 var->transp.offset = 0; in stste_encode_var()
1900 var->transp.length = 0; in stste_encode_var()
1901 var->transp.msb_right = 0; in stste_encode_var()
1902 var->xres_virtual = sttt_xres_virtual; in stste_encode_var()
1903 linelen = var->xres_virtual * var->bits_per_pixel / 8; in stste_encode_var()
1904 ovsc_addlen = linelen * (sttt_yres_virtual - st_yres); in stste_encode_var()
1907 var->yres_virtual = var->yres; in stste_encode_var()
1909 if (par->yres_virtual) in stste_encode_var()
1910 var->yres_virtual = par->yres_virtual; in stste_encode_var()
1913 var->yres_virtual = screen_len / linelen; in stste_encode_var()
1916 var->yres_virtual = 2 * var->yres; in stste_encode_var()
1918 var->yres_virtual = var->yres + hwscroll * 16; in stste_encode_var()
1920 var->xoffset = 0; in stste_encode_var()
1922 var->yoffset = (par->screen_base - screen_base) / linelen; in stste_encode_var()
1924 var->yoffset = 0; in stste_encode_var()
1925 var->nonstd = 0; in stste_encode_var()
1926 var->activate = 0; in stste_encode_var()
1927 var->vmode = FB_VMODE_NONINTERLACED; in stste_encode_var()
1934 par->hw.st.mode = shifter_tt.st_shiftmode; in stste_get_par()
1935 par->hw.st.sync = shifter_st.syncmode; in stste_get_par()
1940 par->screen_base = atari_stram_to_virt(addr); in stste_get_par()
1945 shifter_tt.st_shiftmode = par->hw.st.mode; in stste_set_par()
1946 shifter_st.syncmode = par->hw.st.sync; in stste_set_par()
1948 if (current_par.screen_base != par->screen_base) in stste_set_par()
1949 fbhw->set_screen_base(par->screen_base); in stste_set_par()
2066 /* ------------------- External Video ---------------------- */
2072 strcpy(fix->id, "Unknown Extern"); in ext_encode_fix()
2073 fix->smem_start = external_addr; in ext_encode_fix()
2074 fix->smem_len = PAGE_ALIGN(external_len); in ext_encode_fix()
2076 fix->type = FB_TYPE_PACKED_PIXELS; in ext_encode_fix()
2079 fix->visual = in ext_encode_fix()
2089 case -1: /* truecolor */ in ext_encode_fix()
2090 fix->type = FB_TYPE_PACKED_PIXELS; in ext_encode_fix()
2091 fix->visual = FB_VISUAL_TRUECOLOR; in ext_encode_fix()
2094 fix->type = FB_TYPE_PACKED_PIXELS; in ext_encode_fix()
2095 fix->visual = visual; in ext_encode_fix()
2098 fix->type = FB_TYPE_PLANES; in ext_encode_fix()
2099 fix->visual = visual; in ext_encode_fix()
2102 fix->type = FB_TYPE_INTERLEAVED_PLANES; in ext_encode_fix()
2103 fix->type_aux = 2; in ext_encode_fix()
2104 fix->visual = visual; in ext_encode_fix()
2108 fix->xpanstep = 0; in ext_encode_fix()
2109 fix->ypanstep = 0; in ext_encode_fix()
2110 fix->ywrapstep = 0; in ext_encode_fix()
2111 fix->line_length = par->next_line; in ext_encode_fix()
2119 if (var->bits_per_pixel > myvar->bits_per_pixel || in ext_decode_var()
2120 var->xres > myvar->xres || in ext_decode_var()
2121 var->xres_virtual > myvar->xres_virtual || in ext_decode_var()
2122 var->yres > myvar->yres || in ext_decode_var()
2123 var->xoffset > 0 || in ext_decode_var()
2124 var->yoffset > 0) in ext_decode_var()
2125 return -EINVAL; in ext_decode_var()
2127 par->next_line = external_xres_virtual * external_depth / 8; in ext_decode_var()
2134 var->red.offset = 0; in ext_encode_var()
2135 var->red.length = (external_pmode == -1) ? external_depth / 3 : in ext_encode_var()
2137 var->red.msb_right = 0; in ext_encode_var()
2138 var->grayscale = 0; in ext_encode_var()
2140 var->pixclock = 31041; in ext_encode_var()
2141 var->left_margin = 120; /* these are surely incorrect */ in ext_encode_var()
2142 var->right_margin = 100; in ext_encode_var()
2143 var->upper_margin = 8; in ext_encode_var()
2144 var->lower_margin = 16; in ext_encode_var()
2145 var->hsync_len = 140; in ext_encode_var()
2146 var->vsync_len = 30; in ext_encode_var()
2148 var->height = -1; in ext_encode_var()
2149 var->width = -1; in ext_encode_var()
2151 var->sync = 0; in ext_encode_var()
2153 var->xres = external_xres; in ext_encode_var()
2154 var->yres = external_yres; in ext_encode_var()
2155 var->xres_virtual = external_xres_virtual; in ext_encode_var()
2156 var->bits_per_pixel = external_depth; in ext_encode_var()
2158 var->blue = var->green = var->red; in ext_encode_var()
2159 var->transp.offset = 0; in ext_encode_var()
2160 var->transp.length = 0; in ext_encode_var()
2161 var->transp.msb_right = 0; in ext_encode_var()
2162 var->yres_virtual = var->yres; in ext_encode_var()
2163 var->xoffset = 0; in ext_encode_var()
2164 var->yoffset = 0; in ext_encode_var()
2165 var->nonstd = 0; in ext_encode_var()
2166 var->activate = 0; in ext_encode_var()
2167 var->vmode = FB_VMODE_NONINTERLACED; in ext_encode_var()
2173 par->screen_base = external_screen_base; in ext_get_par()
2194 unsigned char colmask = (1 << external_bitspercol) - 1; in ext_setcolreg()
2234 myvar->xres = external_xres; in ext_detect()
2235 myvar->xres_virtual = external_xres_virtual; in ext_detect()
2236 myvar->yres = external_yres; in ext_detect()
2237 myvar->bits_per_pixel = external_depth; in ext_detect()
2244 /* ------ This is the same for most hardware types -------- */
2259 struct atafb_par *par = info->par; in pan_display()
2261 if (!fbhw->set_screen_base || in pan_display()
2262 (!ATARIHW_PRESENT(EXTD_SHIFTER) && var->xoffset)) in pan_display()
2263 return -EINVAL; in pan_display()
2264 var->xoffset = round_up(var->xoffset, 16); in pan_display()
2265 par->screen_base = screen_base + in pan_display()
2266 (var->yoffset * info->var.xres_virtual + var->xoffset) in pan_display()
2267 * info->var.bits_per_pixel / 8; in pan_display()
2268 fbhw->set_screen_base(par->screen_base); in pan_display()
2272 /* ------------ Interfaces to hardware functions ------------ */
2330 fbhw->get_par(par); in ata_get_par()
2335 fbhw->set_par(par); in ata_set_par()
2352 err = fbhw->decode_var(var, &par); in do_fb_set_var()
2355 activate = var->activate; in do_fb_set_var()
2356 if (((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) && isactive) in do_fb_set_var()
2358 fbhw->encode_var(var, &par); in do_fb_set_var()
2359 var->activate = activate; in do_fb_set_var()
2363 /* fbhw->encode_fix() must be called with fb_info->mm_lock held
2364 * if it is called after the register_framebuffer() - not a case here
2370 // Get fix directly (case con == -1 before)?? in atafb_get_fix()
2371 err = fbhw->decode_var(&info->var, &par); in atafb_get_fix()
2375 err = fbhw->encode_fix(fix, &par); in atafb_get_fix()
2384 fbhw->encode_var(var, &par); in atafb_get_var()
2394 atafb_get_var(&info->var, info); in atafb_set_disp()
2395 atafb_get_fix(&info->fix, info); in atafb_set_disp()
2398 info->screen_base = (external_addr ? external_screen_base : in atafb_set_disp()
2399 atari_stram_to_virt(info->fix.smem_start)); in atafb_set_disp()
2405 if (!fbhw->pan_display) in atafb_pan_display()
2406 return -EINVAL; in atafb_pan_display()
2408 return fbhw->pan_display(var, info); in atafb_pan_display()
2417 struct atafb_par *par = info->par; in atafb_fillrect()
2421 if (!rect->width || !rect->height) in atafb_fillrect()
2425 if (info->var.bits_per_pixel == 16) { in atafb_fillrect()
2435 x2 = rect->dx + rect->width; in atafb_fillrect()
2436 y2 = rect->dy + rect->height; in atafb_fillrect()
2437 x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual; in atafb_fillrect()
2438 y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual; in atafb_fillrect()
2439 width = x2 - rect->dx; in atafb_fillrect()
2440 height = y2 - rect->dy; in atafb_fillrect()
2442 if (info->var.bits_per_pixel == 1) in atafb_fillrect()
2443 atafb_mfb_fillrect(info, par->next_line, rect->color, in atafb_fillrect()
2444 rect->dy, rect->dx, height, width); in atafb_fillrect()
2445 else if (info->var.bits_per_pixel == 2) in atafb_fillrect()
2446 atafb_iplan2p2_fillrect(info, par->next_line, rect->color, in atafb_fillrect()
2447 rect->dy, rect->dx, height, width); in atafb_fillrect()
2448 else if (info->var.bits_per_pixel == 4) in atafb_fillrect()
2449 atafb_iplan2p4_fillrect(info, par->next_line, rect->color, in atafb_fillrect()
2450 rect->dy, rect->dx, height, width); in atafb_fillrect()
2452 atafb_iplan2p8_fillrect(info, par->next_line, rect->color, in atafb_fillrect()
2453 rect->dy, rect->dx, height, width); in atafb_fillrect()
2460 struct atafb_par *par = info->par; in atafb_copyarea()
2466 if (info->var.bits_per_pixel == 16) { in atafb_copyarea()
2472 /* clip the destination */ in atafb_copyarea()
2473 x2 = area->dx + area->width; in atafb_copyarea()
2474 y2 = area->dy + area->height; in atafb_copyarea()
2475 dx = area->dx > 0 ? area->dx : 0; in atafb_copyarea()
2476 dy = area->dy > 0 ? area->dy : 0; in atafb_copyarea()
2477 x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual; in atafb_copyarea()
2478 y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual; in atafb_copyarea()
2479 width = x2 - dx; in atafb_copyarea()
2480 height = y2 - dy; in atafb_copyarea()
2482 if (area->sx + dx < area->dx || area->sy + dy < area->dy) in atafb_copyarea()
2486 sx = area->sx + (dx - area->dx); in atafb_copyarea()
2487 sy = area->sy + (dy - area->dy); in atafb_copyarea()
2490 if (sx + width > info->var.xres_virtual || in atafb_copyarea()
2491 sy + height > info->var.yres_virtual) in atafb_copyarea()
2500 if (info->var.bits_per_pixel == 1) in atafb_copyarea()
2501 atafb_mfb_copyarea(info, par->next_line, sy, sx, dy, dx, height, width); in atafb_copyarea()
2502 else if (info->var.bits_per_pixel == 2) in atafb_copyarea()
2503 atafb_iplan2p2_copyarea(info, par->next_line, sy, sx, dy, dx, height, width); in atafb_copyarea()
2504 else if (info->var.bits_per_pixel == 4) in atafb_copyarea()
2505 atafb_iplan2p4_copyarea(info, par->next_line, sy, sx, dy, dx, height, width); in atafb_copyarea()
2507 atafb_iplan2p8_copyarea(info, par->next_line, sy, sx, dy, dx, height, width); in atafb_copyarea()
2514 struct atafb_par *par = info->par; in atafb_imageblit()
2520 if (info->var.bits_per_pixel == 16) { in atafb_imageblit()
2531 x2 = image->dx + image->width; in atafb_imageblit()
2532 y2 = image->dy + image->height; in atafb_imageblit()
2533 dx = image->dx; in atafb_imageblit()
2534 dy = image->dy; in atafb_imageblit()
2535 x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual; in atafb_imageblit()
2536 y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual; in atafb_imageblit()
2537 width = x2 - dx; in atafb_imageblit()
2538 height = y2 - dy; in atafb_imageblit()
2540 if (image->depth == 1) { in atafb_imageblit()
2542 src = image->data; in atafb_imageblit()
2543 pitch = (image->width + 7) / 8; in atafb_imageblit()
2544 while (height--) { in atafb_imageblit()
2546 if (info->var.bits_per_pixel == 1) in atafb_imageblit()
2547 atafb_mfb_linefill(info, par->next_line, in atafb_imageblit()
2549 image->bg_color, image->fg_color); in atafb_imageblit()
2550 else if (info->var.bits_per_pixel == 2) in atafb_imageblit()
2551 atafb_iplan2p2_linefill(info, par->next_line, in atafb_imageblit()
2553 image->bg_color, image->fg_color); in atafb_imageblit()
2554 else if (info->var.bits_per_pixel == 4) in atafb_imageblit()
2555 atafb_iplan2p4_linefill(info, par->next_line, in atafb_imageblit()
2557 image->bg_color, image->fg_color); in atafb_imageblit()
2559 atafb_iplan2p8_linefill(info, par->next_line, in atafb_imageblit()
2561 image->bg_color, image->fg_color); in atafb_imageblit()
2566 c2p_iplan2(info->screen_base, image->data, dx, dy, width, in atafb_imageblit()
2567 height, par->next_line, image->width, in atafb_imageblit()
2568 info->var.bits_per_pixel); in atafb_imageblit()
2580 return -EFAULT; in atafb_ioctl()
2587 return -EFAULT; in atafb_ioctl()
2592 return -EINVAL; in atafb_ioctl()
2606 if (fbhw->blank && !fbhw->blank(blank)) in atafb_blank()
2638 err = fbhw->decode_var(var, &par); in atafb_check_var()
2643 fbhw->encode_var(var, &par); in atafb_check_var()
2651 struct atafb_par *par = info->par; in atafb_set_par()
2654 fbhw->decode_var(&info->var, par); in atafb_set_par()
2655 mutex_lock(&info->mm_lock); in atafb_set_par()
2656 fbhw->encode_fix(&info->fix, par); in atafb_set_par()
2657 mutex_unlock(&info->mm_lock); in atafb_set_par()
2689 var = atafb_predefined[default_par - 1]; in check_default_par()
2696 var = atafb_predefined[detected_mode - 1]; /* autodetect */ in check_default_par()
2709 var = atafb_predefined[default_par - 1]; in check_default_par()
2729 * [;<screen mem length>[;<vgaiobase>[;<bits-per-col>[;<colorreg-type> in atafb_setup_ext()
2730 * [;<xres-virtual>]]]]] in atafb_setup_ext()
2733 * <xres_virtual>: hardware's x-resolution (f.e. ProMST) in atafb_setup_ext()
2735 * Even xres_virtual is available, we neither support panning nor hw-scrolling! in atafb_setup_ext()
2769 planes = -1; /* true color */ in atafb_setup_ext()
2843 * <xres>: x-resolution in atafb_setup_int()
2844 * <yres>: y-resolution in atafb_setup_int()
2933 atafb_predefined[default_par - 1].xres = xres; in atafb_setup_user()
2934 atafb_predefined[default_par - 1].yres = yres; in atafb_setup_user()
2935 atafb_predefined[default_par - 1].bits_per_pixel = depth; in atafb_setup_user()
2974 /* external pixelclock in kHz --> ps */ in atafb_setup()
2996 return -ENODEV; in atafb_probe()
2998 dev_dbg(&pdev->dev, "%s: start\n", __func__); in atafb_probe()
3003 dev_dbg(&pdev->dev, "initializing external hw\n"); in atafb_probe()
3012 dev_dbg(&pdev->dev, "initializing TT hw\n"); in atafb_probe()
3021 dev_dbg(&pdev->dev, "initializing Falcon hw\n"); in atafb_probe()
3036 dev_dbg(&pdev->dev, "initializing ST/E hw\n"); in atafb_probe()
3044 dev_warn(&pdev->dev, in atafb_probe()
3048 /* Nobody will ever see this message :-) */ in atafb_probe()
3054 /* Atari-TOS defaults if no boot option present */ in atafb_probe()
3062 detected_mode = fbhw->detect(); in atafb_probe()
3073 pad = -(unsigned long)screen_base & (PAGE_SIZE - 1); in atafb_probe()
3076 screen_len = (mem_req - pad - ovsc_offset) & PAGE_MASK; in atafb_probe()
3080 * write-through also for internal video hardware! */ in atafb_probe()
3085 dev_info(&pdev->dev, "phys_screen_base %lx screen_len %d\n", in atafb_probe()
3103 // strcpy(fb_info.mode->name, "Atari Builtin "); in atafb_probe()
3106 do_fb_set_var(&atafb_predefined[default_par - 1], 1); in atafb_probe()
3121 return -EINVAL; in atafb_probe()
3132 dev_info(&pdev->dev, "Determined %dx%d, depth %d\n", fb_info.var.xres, in atafb_probe()
3136 dev_info(&pdev->dev, " virtual %dx%d\n", in atafb_probe()
3150 return -EINVAL; in atafb_probe()
3163 if (fbhw->blank) in atafb_shutdown()
3164 fbhw->blank(0); in atafb_shutdown()
3179 return -ENODEV; in atafb_init()
3181 pdev = platform_device_register_simple("atafb", -1, NULL, 0); in atafb_init()