Lines Matching +full:device +full:- +full:width
2 * linux/drivers/video/tgafb.c -- DEC 21030 TGA frame buffer device
19 #include <linux/device.h>
37 #define TGA_BUS_TC(dev) (dev->bus == &tc_bus_type)
59 static int tgafb_register(struct device *dev);
60 static void tgafb_unregister(struct device *dev);
116 return tgafb_register(&pdev->dev); in tgafb_pci_register()
121 tgafb_unregister(&pdev->dev); in tgafb_pci_unregister()
129 static int tgafb_tc_register(struct device *);
130 static int tgafb_tc_unregister(struct device *);
133 { "DEC ", "PMAGD-AA" },
149 static int tgafb_tc_register(struct device *dev) in tgafb_tc_register()
157 static int tgafb_tc_unregister(struct device *dev) in tgafb_tc_unregister()
167 * tgafb_check_var - Optional function. Validates a var passed in.
174 struct tga_par *par = (struct tga_par *)info->par; in tgafb_check_var()
176 if (par->tga_type == TGA_TYPE_8PLANE) { in tgafb_check_var()
177 if (var->bits_per_pixel != 8) in tgafb_check_var()
178 return -EINVAL; in tgafb_check_var()
180 if (var->bits_per_pixel != 32) in tgafb_check_var()
181 return -EINVAL; in tgafb_check_var()
183 var->red.length = var->green.length = var->blue.length = 8; in tgafb_check_var()
184 if (var->bits_per_pixel == 32) { in tgafb_check_var()
185 var->red.offset = 16; in tgafb_check_var()
186 var->green.offset = 8; in tgafb_check_var()
187 var->blue.offset = 0; in tgafb_check_var()
190 if (var->xres_virtual != var->xres || var->yres_virtual != var->yres) in tgafb_check_var()
191 return -EINVAL; in tgafb_check_var()
192 if (var->xres * var->yres * (var->bits_per_pixel >> 3) > info->fix.smem_len) in tgafb_check_var()
193 return -EINVAL; in tgafb_check_var()
194 if (var->nonstd) in tgafb_check_var()
195 return -EINVAL; in tgafb_check_var()
196 if (1000000000 / var->pixclock > TGA_PLL_MAX_FREQ) in tgafb_check_var()
197 return -EINVAL; in tgafb_check_var()
198 if ((var->vmode & FB_VMODE_MASK) != FB_VMODE_NONINTERLACED) in tgafb_check_var()
199 return -EINVAL; in tgafb_check_var()
201 /* Some of the acceleration routines assume the line width is in tgafb_check_var()
203 if (var->xres * (par->tga_type == TGA_TYPE_8PLANE ? 1 : 4) % 8) in tgafb_check_var()
204 return -EINVAL; in tgafb_check_var()
210 * tgafb_set_par - Optional function. Alters the hardware state.
241 struct tga_par *par = (struct tga_par *) info->par;
242 int tga_bus_pci = dev_is_pci(par->dev);
243 int tga_bus_tc = TGA_BUS_TC(par->dev);
249 htimings = (((info->var.xres/4) & TGA_HORIZ_ACT_LSB)
250 | (((info->var.xres/4) & 0x600 << 19) & TGA_HORIZ_ACT_MSB));
251 vtimings = (info->var.yres & TGA_VERT_ACTIVE);
252 htimings |= ((info->var.right_margin/4) << 9) & TGA_HORIZ_FP;
253 vtimings |= (info->var.lower_margin << 11) & TGA_VERT_FP;
254 htimings |= ((info->var.hsync_len/4) << 14) & TGA_HORIZ_SYNC;
255 vtimings |= (info->var.vsync_len << 16) & TGA_VERT_SYNC;
256 htimings |= ((info->var.left_margin/4) << 21) & TGA_HORIZ_BP;
257 vtimings |= (info->var.upper_margin << 22) & TGA_VERT_BP;
259 if (info->var.sync & FB_SYNC_HOR_HIGH_ACT)
261 if (info->var.sync & FB_SYNC_VERT_HIGH_ACT)
264 par->htimings = htimings;
265 par->vtimings = vtimings;
267 par->sync_on_green = !!(info->var.sync & FB_SYNC_ON_GREEN);
270 par->xres = info->var.xres;
271 par->yres = info->var.yres;
272 par->pll_freq = pll_freq = 1000000000 / info->var.pixclock;
273 par->bits_per_pixel = info->var.bits_per_pixel;
274 info->fix.line_length = par->xres * (par->bits_per_pixel >> 3);
276 tga_type = par->tga_type;
286 (par->sync_on_green ? 0x0 : 0x00010000),
312 BT485_WRITE(par, 0xa2 | (par->sync_on_green ? 0x8 : 0x0),
341 (par->sync_on_green ? 0xc0 : 0x40));
356 } else { /* 24-plane or 24plusZ */
362 (par->sync_on_green ? 0xc0 : 0x40));
416 /* Finally, enable video scan (and pray for the monitor... :-) */
425 int delta = f - (TGA_PLL_BASE_FREQ * (X)) / (r << shift); \
427 delta = -delta; \
487 m = ((n + 3) / 7) - 1;
492 m = (n / 6) - 1;
500 vr--;
513 * tgafb_setcolreg - Optional function. Sets a color register.
525 struct tga_par *par = (struct tga_par *) info->par;
526 int tga_bus_pci = dev_is_pci(par->dev);
527 int tga_bus_tc = TGA_BUS_TC(par->dev);
535 if (par->tga_type == TGA_TYPE_8PLANE && tga_bus_pci) {
541 } else if (par->tga_type == TGA_TYPE_8PLANE && tga_bus_tc) {
550 ((u32 *)info->pseudo_palette)[regno] = value;
564 * tgafb_blank - Optional function. Blanks the display.
571 struct tga_par *par = (struct tga_par *) info->par;
584 if (par->vesa_blanked) {
587 par->vesa_blanked = 0;
600 par->vesa_blanked = 1;
606 par->vesa_blanked = 1;
613 par->vesa_blanked = 1;
629 struct tga_par *par = (struct tga_par *) info->par;
630 u32 fgcolor, bgcolor, dx, dy, width, height, vxres, vyres, pixelmask; local
637 is8bpp = info->var.bits_per_pixel == 8;
639 dx = image->dx;
640 dy = image->dy;
641 width = image->width;
642 height = image->height;
643 vxres = info->var.xres_virtual;
644 vyres = info->var.yres_virtual;
645 line_length = info->fix.line_length;
646 rincr = (width + 7) / 8;
649 if (unlikely(width == 0))
654 if (dx + width > vxres)
655 width = vxres - dx;
657 height = vyres - dy;
659 regs_base = par->tga_regs_base;
660 fb_base = par->tga_fb_base;
662 /* Expand the color values to fill 32-bits. */
665 fgcolor = image->fg_color;
666 bgcolor = image->bg_color;
674 fgcolor = ((u32 *)info->pseudo_palette)[fgcolor];
676 bgcolor = ((u32 *)info->pseudo_palette)[bgcolor];
687 pos &= -4;
691 pos &= -8;
694 data = (const unsigned char *) image->data;
702 if (width + shift <= 32) {
708 /* Avoid a shift by 32; width > 0 implied. */
709 pixelmask = (2ul << (width - 1)) - 1;
714 bwidth = (width + 7) / 8;
745 bwidth = (width / 8) & -4;
760 pixelmask = (1ul << (width & 31)) - 1;
767 bwidth = ((width & 31) + 7) / 8;
787 Here we split the write into 16-bit spans. This allows
789 be required by writing 24-bit spans. */
795 bwidth = (width / 8) & -2;
809 pixelmask = ((1ul << (width & 15)) - 1) << shift;
816 bwidth = (width & 15) > 8;
842 struct tga_par *par = (struct tga_par *) info->par;
843 u32 color, dx, dy, width, height, vxres, vyres; local
844 u32 *palette = ((u32 *)info->pseudo_palette);
849 dx = image->dx;
850 dy = image->dy;
851 width = image->width;
852 height = image->height;
853 vxres = info->var.xres_virtual;
854 vyres = info->var.yres_virtual;
855 line_length = info->fix.line_length;
860 if (dx + width > vxres)
861 width = vxres - dx;
863 height = vyres - dy;
865 fb_base = par->tga_fb_base;
868 data = image->data;
872 for (j = 0; j < width; j++) {
881 * tgafb_imageblit - REQUIRED function. Can use generic routines if
891 unsigned int is8bpp = info->var.bits_per_pixel == 8;
894 if (image->depth == 1) {
903 if (image->depth == info->var.bits_per_pixel) {
908 /* If 24-plane FB and the image is 8-plane with CLUT, we can do it. */
909 if (!is8bpp && image->depth == 8) {
918 * tgafb_fillrect - REQUIRED function. Can use generic routines if
928 struct tga_par *par = (struct tga_par *) info->par;
929 int is8bpp = info->var.bits_per_pixel == 8;
930 u32 dx, dy, width, height, vxres, vyres, color; local
935 dx = rect->dx;
936 dy = rect->dy;
937 width = rect->width;
938 height = rect->height;
939 vxres = info->var.xres_virtual;
940 vyres = info->var.yres_virtual;
941 line_length = info->fix.line_length;
942 regs_base = par->tga_regs_base;
943 fb_base = par->tga_fb_base;
946 if (dx > vxres || dy > vyres || !width || !height)
948 if (dx + width > vxres)
949 width = vxres - dx;
951 height = vyres - dy;
959 if (rect->rop != ROP_COPY) {
965 color = rect->color;
973 color = ((u32 *)info->pseudo_palette)[color];
996 the width of the screen so that we can take advantage of this
998 if (width == line_length) {
999 width *= height;
1007 pos &= -4;
1009 if (width <= 2048) {
1012 data = (width - 1) | align;
1020 unsigned long nwidth = width & -2048;
1023 fdata = (2048 - 1) | align;
1024 ldata = ((width & 2047) - 1) | align;
1029 if (j < width)
1044 * tgafb_copyarea - REQUIRED function. Can use generic routines if
1059 u32 height, u32 width) argument
1061 struct tga_par *par = (struct tga_par *) info->par;
1062 void __iomem *tga_regs = par->tga_regs_base;
1070 n64 = (height * width) / 64;
1073 spos = (sy + height) * width;
1074 dpos = (dy + height) * width;
1077 spos -= 64;
1078 dpos -= 64;
1085 spos = sy * width;
1086 dpos = dy * width;
1104 u32 height, u32 width) argument
1106 struct tga_par *par = (struct tga_par *) info->par;
1107 void __iomem *tga_regs = par->tga_regs_base;
1108 void __iomem *tga_fb = par->tga_fb_base;
1118 n16 = (height * width) / 16;
1121 src = tga_fb + (sy + height) * width * 4;
1122 dst = tga_fb + (dy + height) * width * 4;
1125 src -= 64;
1126 dst -= 64;
1133 src = tga_fb + sy * width * 4;
1134 dst = tga_fb + dy * width * 4;
1153 u32 height, u32 width, u32 line_length, argument
1156 struct tga_par *par = (struct tga_par *) info->par;
1165 if ((dx | sx | width) & 7) {
1172 dy += height - 1;
1173 sy += height - 1;
1174 yincr = -yincr;
1176 backward = dy == sy && dx > sx && dx < sx + width;
1183 depos += width;
1184 sepos += width;
1188 n32 = width / 32;
1189 last_step = width % 32;
1192 mask_last = (1ul << last_step) - 1;
1198 step = -32;
1199 last_step = -last_step;
1200 sepos -= 32;
1201 depos -= 32;
1204 tga_regs = par->tga_regs_base;
1205 tga_fb = par->tga_fb_base;
1224 __raw_writel(sfb - tga_fb, tga_regs+TGA_COPY64_SRC);
1226 __raw_writel(dfb - tga_fb, tga_regs+TGA_COPY64_DST);
1232 j--;
1244 sfb += last_step - step;
1245 dfb += last_step - step;
1263 unsigned long dx, dy, width, height, sx, sy, vxres, vyres; local
1266 dx = area->dx;
1267 dy = area->dy;
1268 width = area->width;
1269 height = area->height;
1270 sx = area->sx;
1271 sy = area->sy;
1272 vxres = info->var.xres_virtual;
1273 vyres = info->var.yres_virtual;
1274 line_length = info->fix.line_length;
1281 if (dx + width > vxres)
1282 width = vxres - dx;
1284 height = vyres - dy;
1287 if (sx + width > vxres || sy + height > vyres)
1290 bpp = info->var.bits_per_pixel;
1293 if (!(line_length & 63) && width * (bpp >> 3) == line_length) {
1295 copyarea_line_8bpp(info, dy, sy, height, width);
1297 copyarea_line_32bpp(info, dy, sy, height, width);
1308 width, line_length, area);
1319 struct tga_par *par = (struct tga_par *)info->par;
1320 int tga_bus_pci = dev_is_pci(par->dev);
1321 int tga_bus_tc = TGA_BUS_TC(par->dev);
1322 u8 tga_type = par->tga_type;
1329 tga_type_name = "Digital ZLXp-E1";
1331 tga_type_name = "Digital ZLX-E1";
1336 tga_type_name = "Digital ZLXp-E2";
1338 tga_type_name = "Digital ZLX-E2";
1343 tga_type_name = "Digital ZLXp-E3";
1345 tga_type_name = "Digital ZLX-E3";
1354 strscpy(info->fix.id, tga_type_name, sizeof(info->fix.id));
1356 info->fix.type = FB_TYPE_PACKED_PIXELS;
1357 info->fix.type_aux = 0;
1358 info->fix.visual = (tga_type == TGA_TYPE_8PLANE
1362 info->fix.smem_start = (size_t) par->tga_fb_base;
1363 info->fix.smem_len = memory_size;
1364 info->fix.mmio_start = (size_t) par->tga_regs_base;
1365 info->fix.mmio_len = 512;
1367 info->fix.xpanstep = 0;
1368 info->fix.ypanstep = 0;
1369 info->fix.ywrapstep = 0;
1371 info->fix.accel = FB_ACCEL_DEC_TGA;
1375 * set them here for 24-plane cards.
1378 info->var.red.length = 8;
1379 info->var.green.length = 8;
1380 info->var.blue.length = 8;
1381 info->var.red.offset = 16;
1382 info->var.green.offset = 8;
1383 info->var.blue.offset = 0;
1394 static int tgafb_register(struct device *dev)
1421 /* Enable device in PCI config. */
1423 printk(KERN_ERR "tgafb: Cannot enable PCI device\n");
1424 return -ENODEV;
1430 return -ENOMEM;
1432 par = info->par;
1436 ret = -ENODEV;
1442 bar0_start = to_tc_dev(dev)->resource.start;
1443 bar0_len = to_tc_dev(dev)->resource.end - bar0_start + 1;
1459 par->dev = dev;
1460 par->tga_mem_base = mem_base;
1461 par->tga_fb_base = mem_base + fb_offset_presets[tga_type];
1462 par->tga_regs_base = mem_base + TGA_REGS_OFFSET;
1463 par->tga_type = tga_type;
1465 par->tga_chip_rev = (to_pci_dev(dev))->revision;
1467 par->tga_chip_rev = TGA_READ_REG(par, TGA_START_REG) & 0xff;
1470 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA |
1472 info->fbops = &tgafb_ops;
1473 info->screen_base = par->tga_fb_base;
1474 info->pseudo_palette = par->palette;
1488 ret = fb_find_mode(&info->var, info,
1494 ret = -EINVAL;
1498 if (fb_alloc_cmap(&info->cmap, 256, 0)) {
1500 ret = -ENOMEM;
1508 ret = -EINVAL;
1514 par->tga_chip_rev);
1515 pr_info("tgafb: at PCI bus %d, device %d, function %d\n",
1516 to_pci_dev(dev)->bus->number,
1517 PCI_SLOT(to_pci_dev(dev)->devfn),
1518 PCI_FUNC(to_pci_dev(dev)->devfn));
1522 par->tga_chip_rev);
1523 fb_info(info, "%s frame buffer device at 0x%lx\n",
1524 info->fix.id, (long)bar0_start);
1529 fb_dealloc_cmap(&info->cmap);
1539 static void tgafb_unregister(struct device *dev)
1551 par = info->par;
1553 fb_dealloc_cmap(&info->cmap);
1554 iounmap(par->tga_mem_base);
1560 bar0_start = to_tc_dev(dev)->resource.start;
1561 bar0_len = to_tc_dev(dev)->resource.end - bar0_start + 1;
1602 return -ENODEV;