Lines Matching +full:device +full:- +full:width
2 * linux/drivers/video/tgafb.c -- DEC 21030 TGA frame buffer device
18 #include <linux/device.h>
36 #define TGA_BUS_TC(dev) (dev->bus == &tc_bus_type)
58 static int tgafb_register(struct device *dev);
59 static void tgafb_unregister(struct device *dev);
109 return tgafb_register(&pdev->dev); in tgafb_pci_register()
114 tgafb_unregister(&pdev->dev); in tgafb_pci_unregister()
122 static int tgafb_tc_register(struct device *);
123 static int tgafb_tc_unregister(struct device *);
126 { "DEC ", "PMAGD-AA" },
142 static int tgafb_tc_register(struct device *dev) in tgafb_tc_register()
150 static int tgafb_tc_unregister(struct device *dev) in tgafb_tc_unregister()
160 * tgafb_check_var - Optional function. Validates a var passed in.
167 struct tga_par *par = (struct tga_par *)info->par; in tgafb_check_var()
169 if (par->tga_type == TGA_TYPE_8PLANE) { in tgafb_check_var()
170 if (var->bits_per_pixel != 8) in tgafb_check_var()
171 return -EINVAL; in tgafb_check_var()
173 if (var->bits_per_pixel != 32) in tgafb_check_var()
174 return -EINVAL; in tgafb_check_var()
176 var->red.length = var->green.length = var->blue.length = 8; in tgafb_check_var()
177 if (var->bits_per_pixel == 32) { in tgafb_check_var()
178 var->red.offset = 16; in tgafb_check_var()
179 var->green.offset = 8; in tgafb_check_var()
180 var->blue.offset = 0; in tgafb_check_var()
183 if (var->xres_virtual != var->xres || var->yres_virtual != var->yres) in tgafb_check_var()
184 return -EINVAL; in tgafb_check_var()
185 if (var->xres * var->yres * (var->bits_per_pixel >> 3) > info->fix.smem_len) in tgafb_check_var()
186 return -EINVAL; in tgafb_check_var()
187 if (var->nonstd) in tgafb_check_var()
188 return -EINVAL; in tgafb_check_var()
189 if (1000000000 / var->pixclock > TGA_PLL_MAX_FREQ) in tgafb_check_var()
190 return -EINVAL; in tgafb_check_var()
191 if ((var->vmode & FB_VMODE_MASK) != FB_VMODE_NONINTERLACED) in tgafb_check_var()
192 return -EINVAL; in tgafb_check_var()
194 /* Some of the acceleration routines assume the line width is in tgafb_check_var()
196 if (var->xres * (par->tga_type == TGA_TYPE_8PLANE ? 1 : 4) % 8) in tgafb_check_var()
197 return -EINVAL; in tgafb_check_var()
203 * tgafb_set_par - Optional function. Alters the hardware state.
234 struct tga_par *par = (struct tga_par *) info->par;
235 int tga_bus_pci = dev_is_pci(par->dev);
236 int tga_bus_tc = TGA_BUS_TC(par->dev);
242 htimings = (((info->var.xres/4) & TGA_HORIZ_ACT_LSB)
243 | (((info->var.xres/4) & 0x600 << 19) & TGA_HORIZ_ACT_MSB));
244 vtimings = (info->var.yres & TGA_VERT_ACTIVE);
245 htimings |= ((info->var.right_margin/4) << 9) & TGA_HORIZ_FP;
246 vtimings |= (info->var.lower_margin << 11) & TGA_VERT_FP;
247 htimings |= ((info->var.hsync_len/4) << 14) & TGA_HORIZ_SYNC;
248 vtimings |= (info->var.vsync_len << 16) & TGA_VERT_SYNC;
249 htimings |= ((info->var.left_margin/4) << 21) & TGA_HORIZ_BP;
250 vtimings |= (info->var.upper_margin << 22) & TGA_VERT_BP;
252 if (info->var.sync & FB_SYNC_HOR_HIGH_ACT)
254 if (info->var.sync & FB_SYNC_VERT_HIGH_ACT)
257 par->htimings = htimings;
258 par->vtimings = vtimings;
260 par->sync_on_green = !!(info->var.sync & FB_SYNC_ON_GREEN);
263 par->xres = info->var.xres;
264 par->yres = info->var.yres;
265 par->pll_freq = pll_freq = 1000000000 / info->var.pixclock;
266 par->bits_per_pixel = info->var.bits_per_pixel;
267 info->fix.line_length = par->xres * (par->bits_per_pixel >> 3);
269 tga_type = par->tga_type;
279 (par->sync_on_green ? 0x0 : 0x00010000),
305 BT485_WRITE(par, 0xa2 | (par->sync_on_green ? 0x8 : 0x0),
334 (par->sync_on_green ? 0xc0 : 0x40));
349 } else { /* 24-plane or 24plusZ */
355 (par->sync_on_green ? 0xc0 : 0x40));
409 /* Finally, enable video scan (and pray for the monitor... :-) */
418 int delta = f - (TGA_PLL_BASE_FREQ * (X)) / (r << shift); \
420 delta = -delta; \
480 m = ((n + 3) / 7) - 1;
485 m = (n / 6) - 1;
493 vr--;
506 * tgafb_setcolreg - Optional function. Sets a color register.
518 struct tga_par *par = (struct tga_par *) info->par;
519 int tga_bus_pci = dev_is_pci(par->dev);
520 int tga_bus_tc = TGA_BUS_TC(par->dev);
528 if (par->tga_type == TGA_TYPE_8PLANE && tga_bus_pci) {
534 } else if (par->tga_type == TGA_TYPE_8PLANE && tga_bus_tc) {
543 ((u32 *)info->pseudo_palette)[regno] = value;
557 * tgafb_blank - Optional function. Blanks the display.
564 struct tga_par *par = (struct tga_par *) info->par;
577 if (par->vesa_blanked) {
580 par->vesa_blanked = 0;
593 par->vesa_blanked = 1;
599 par->vesa_blanked = 1;
606 par->vesa_blanked = 1;
622 struct tga_par *par = (struct tga_par *) info->par;
623 u32 fgcolor, bgcolor, dx, dy, width, height, vxres, vyres, pixelmask; local
630 is8bpp = info->var.bits_per_pixel == 8;
632 dx = image->dx;
633 dy = image->dy;
634 width = image->width;
635 height = image->height;
636 vxres = info->var.xres_virtual;
637 vyres = info->var.yres_virtual;
638 line_length = info->fix.line_length;
639 rincr = (width + 7) / 8;
642 if (unlikely(width == 0))
647 if (dx + width > vxres)
648 width = vxres - dx;
650 height = vyres - dy;
652 regs_base = par->tga_regs_base;
653 fb_base = par->tga_fb_base;
655 /* Expand the color values to fill 32-bits. */
658 fgcolor = image->fg_color;
659 bgcolor = image->bg_color;
667 fgcolor = ((u32 *)info->pseudo_palette)[fgcolor];
669 bgcolor = ((u32 *)info->pseudo_palette)[bgcolor];
680 pos &= -4;
684 pos &= -8;
687 data = (const unsigned char *) image->data;
695 if (width + shift <= 32) {
701 /* Avoid a shift by 32; width > 0 implied. */
702 pixelmask = (2ul << (width - 1)) - 1;
707 bwidth = (width + 7) / 8;
738 bwidth = (width / 8) & -4;
753 pixelmask = (1ul << (width & 31)) - 1;
760 bwidth = ((width & 31) + 7) / 8;
780 Here we split the write into 16-bit spans. This allows
782 be required by writing 24-bit spans. */
788 bwidth = (width / 8) & -2;
802 pixelmask = ((1ul << (width & 15)) - 1) << shift;
809 bwidth = (width & 15) > 8;
835 struct tga_par *par = (struct tga_par *) info->par;
836 u32 color, dx, dy, width, height, vxres, vyres; local
837 u32 *palette = ((u32 *)info->pseudo_palette);
842 dx = image->dx;
843 dy = image->dy;
844 width = image->width;
845 height = image->height;
846 vxres = info->var.xres_virtual;
847 vyres = info->var.yres_virtual;
848 line_length = info->fix.line_length;
853 if (dx + width > vxres)
854 width = vxres - dx;
856 height = vyres - dy;
858 fb_base = par->tga_fb_base;
861 data = image->data;
865 for (j = 0; j < width; j++) {
874 * tgafb_imageblit - REQUIRED function. Can use generic routines if
884 unsigned int is8bpp = info->var.bits_per_pixel == 8;
887 if (image->depth == 1) {
896 if (image->depth == info->var.bits_per_pixel) {
901 /* If 24-plane FB and the image is 8-plane with CLUT, we can do it. */
902 if (!is8bpp && image->depth == 8) {
911 * tgafb_fillrect - REQUIRED function. Can use generic routines if
921 struct tga_par *par = (struct tga_par *) info->par;
922 int is8bpp = info->var.bits_per_pixel == 8;
923 u32 dx, dy, width, height, vxres, vyres, color; local
928 dx = rect->dx;
929 dy = rect->dy;
930 width = rect->width;
931 height = rect->height;
932 vxres = info->var.xres_virtual;
933 vyres = info->var.yres_virtual;
934 line_length = info->fix.line_length;
935 regs_base = par->tga_regs_base;
936 fb_base = par->tga_fb_base;
939 if (dx > vxres || dy > vyres || !width || !height)
941 if (dx + width > vxres)
942 width = vxres - dx;
944 height = vyres - dy;
952 if (rect->rop != ROP_COPY) {
958 color = rect->color;
966 color = ((u32 *)info->pseudo_palette)[color];
989 the width of the screen so that we can take advantage of this
991 if (width == line_length) {
992 width *= height;
1000 pos &= -4;
1002 if (width <= 2048) {
1005 data = (width - 1) | align;
1013 unsigned long nwidth = width & -2048;
1016 fdata = (2048 - 1) | align;
1017 ldata = ((width & 2047) - 1) | align;
1022 if (j < width)
1037 * tgafb_copyarea - REQUIRED function. Can use generic routines if
1052 u32 height, u32 width) argument
1054 struct tga_par *par = (struct tga_par *) info->par;
1055 void __iomem *tga_regs = par->tga_regs_base;
1063 n64 = (height * width) / 64;
1066 spos = (sy + height) * width;
1067 dpos = (dy + height) * width;
1070 spos -= 64;
1071 dpos -= 64;
1078 spos = sy * width;
1079 dpos = dy * width;
1097 u32 height, u32 width) argument
1099 struct tga_par *par = (struct tga_par *) info->par;
1100 void __iomem *tga_regs = par->tga_regs_base;
1101 void __iomem *tga_fb = par->tga_fb_base;
1111 n16 = (height * width) / 16;
1114 src = tga_fb + (sy + height) * width * 4;
1115 dst = tga_fb + (dy + height) * width * 4;
1118 src -= 64;
1119 dst -= 64;
1126 src = tga_fb + sy * width * 4;
1127 dst = tga_fb + dy * width * 4;
1146 u32 height, u32 width, u32 line_length, argument
1149 struct tga_par *par = (struct tga_par *) info->par;
1158 if ((dx | sx | width) & 7) {
1165 dy += height - 1;
1166 sy += height - 1;
1167 yincr = -yincr;
1169 backward = dy == sy && dx > sx && dx < sx + width;
1176 depos += width;
1177 sepos += width;
1181 n32 = width / 32;
1182 last_step = width % 32;
1185 mask_last = (1ul << last_step) - 1;
1191 step = -32;
1192 last_step = -last_step;
1193 sepos -= 32;
1194 depos -= 32;
1197 tga_regs = par->tga_regs_base;
1198 tga_fb = par->tga_fb_base;
1217 __raw_writel(sfb - tga_fb, tga_regs+TGA_COPY64_SRC);
1219 __raw_writel(dfb - tga_fb, tga_regs+TGA_COPY64_DST);
1225 j--;
1237 sfb += last_step - step;
1238 dfb += last_step - step;
1256 unsigned long dx, dy, width, height, sx, sy, vxres, vyres; local
1259 dx = area->dx;
1260 dy = area->dy;
1261 width = area->width;
1262 height = area->height;
1263 sx = area->sx;
1264 sy = area->sy;
1265 vxres = info->var.xres_virtual;
1266 vyres = info->var.yres_virtual;
1267 line_length = info->fix.line_length;
1274 if (dx + width > vxres)
1275 width = vxres - dx;
1277 height = vyres - dy;
1280 if (sx + width > vxres || sy + height > vyres)
1283 bpp = info->var.bits_per_pixel;
1286 if (!(line_length & 63) && width * (bpp >> 3) == line_length) {
1288 copyarea_line_8bpp(info, dy, sy, height, width);
1290 copyarea_line_32bpp(info, dy, sy, height, width);
1301 width, line_length, area);
1312 struct tga_par *par = (struct tga_par *)info->par;
1313 int tga_bus_pci = dev_is_pci(par->dev);
1314 int tga_bus_tc = TGA_BUS_TC(par->dev);
1315 u8 tga_type = par->tga_type;
1322 tga_type_name = "Digital ZLXp-E1";
1324 tga_type_name = "Digital ZLX-E1";
1329 tga_type_name = "Digital ZLXp-E2";
1331 tga_type_name = "Digital ZLX-E2";
1336 tga_type_name = "Digital ZLXp-E3";
1338 tga_type_name = "Digital ZLX-E3";
1347 strlcpy(info->fix.id, tga_type_name, sizeof(info->fix.id));
1349 info->fix.type = FB_TYPE_PACKED_PIXELS;
1350 info->fix.type_aux = 0;
1351 info->fix.visual = (tga_type == TGA_TYPE_8PLANE
1355 info->fix.smem_start = (size_t) par->tga_fb_base;
1356 info->fix.smem_len = memory_size;
1357 info->fix.mmio_start = (size_t) par->tga_regs_base;
1358 info->fix.mmio_len = 512;
1360 info->fix.xpanstep = 0;
1361 info->fix.ypanstep = 0;
1362 info->fix.ywrapstep = 0;
1364 info->fix.accel = FB_ACCEL_DEC_TGA;
1368 * set them here for 24-plane cards.
1371 info->var.red.length = 8;
1372 info->var.green.length = 8;
1373 info->var.blue.length = 8;
1374 info->var.red.offset = 16;
1375 info->var.green.offset = 8;
1376 info->var.blue.offset = 0;
1387 static int tgafb_register(struct device *dev)
1414 /* Enable device in PCI config. */
1416 printk(KERN_ERR "tgafb: Cannot enable PCI device\n");
1417 return -ENODEV;
1423 return -ENOMEM;
1425 par = info->par;
1429 ret = -ENODEV;
1435 bar0_start = to_tc_dev(dev)->resource.start;
1436 bar0_len = to_tc_dev(dev)->resource.end - bar0_start + 1;
1452 par->dev = dev;
1453 par->tga_mem_base = mem_base;
1454 par->tga_fb_base = mem_base + fb_offset_presets[tga_type];
1455 par->tga_regs_base = mem_base + TGA_REGS_OFFSET;
1456 par->tga_type = tga_type;
1458 par->tga_chip_rev = (to_pci_dev(dev))->revision;
1460 par->tga_chip_rev = TGA_READ_REG(par, TGA_START_REG) & 0xff;
1463 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA |
1465 info->fbops = &tgafb_ops;
1466 info->screen_base = par->tga_fb_base;
1467 info->pseudo_palette = par->palette;
1481 ret = fb_find_mode(&info->var, info,
1487 ret = -EINVAL;
1491 if (fb_alloc_cmap(&info->cmap, 256, 0)) {
1493 ret = -ENOMEM;
1501 ret = -EINVAL;
1507 par->tga_chip_rev);
1508 pr_info("tgafb: at PCI bus %d, device %d, function %d\n",
1509 to_pci_dev(dev)->bus->number,
1510 PCI_SLOT(to_pci_dev(dev)->devfn),
1511 PCI_FUNC(to_pci_dev(dev)->devfn));
1515 par->tga_chip_rev);
1516 fb_info(info, "%s frame buffer device at 0x%lx\n",
1517 info->fix.id, (long)bar0_start);
1522 fb_dealloc_cmap(&info->cmap);
1532 static void tgafb_unregister(struct device *dev)
1544 par = info->par;
1546 fb_dealloc_cmap(&info->cmap);
1547 iounmap(par->tga_mem_base);
1553 bar0_start = to_tc_dev(dev)->resource.start;
1554 bar0_len = to_tc_dev(dev)->resource.end - bar0_start + 1;
1595 return -ENODEV;