Lines Matching +full:col +full:- +full:offset
1 // SPDX-License-Identifier: GPL-2.0-only
6 * (c) 1998-2002 Petr Vandrovec <vandrove@vc.cvut.cz>
33 u_int32_t col; in matroxfb_dh_setcolreg() local
38 if (m2info->fbcon.var.grayscale) { in matroxfb_dh_setcolreg()
42 red = CNVT_TOHW(red, m2info->fbcon.var.red.length); in matroxfb_dh_setcolreg()
43 green = CNVT_TOHW(green, m2info->fbcon.var.green.length); in matroxfb_dh_setcolreg()
44 blue = CNVT_TOHW(blue, m2info->fbcon.var.blue.length); in matroxfb_dh_setcolreg()
45 transp = CNVT_TOHW(transp, m2info->fbcon.var.transp.length); in matroxfb_dh_setcolreg()
47 col = (red << m2info->fbcon.var.red.offset) | in matroxfb_dh_setcolreg()
48 (green << m2info->fbcon.var.green.offset) | in matroxfb_dh_setcolreg()
49 (blue << m2info->fbcon.var.blue.offset) | in matroxfb_dh_setcolreg()
50 (transp << m2info->fbcon.var.transp.offset); in matroxfb_dh_setcolreg()
52 switch (m2info->fbcon.var.bits_per_pixel) { in matroxfb_dh_setcolreg()
54 m2info->cmap[regno] = col | (col << 16); in matroxfb_dh_setcolreg()
57 m2info->cmap[regno] = col; in matroxfb_dh_setcolreg()
70 struct matrox_fb_info *minfo = m2info->primary_dev; in matroxfb_dh_restore()
86 if (minfo->outputs[1].src == MATROXFB_SRC_CRTC2) { in matroxfb_dh_restore()
87 if (minfo->devflags.g450dac) { in matroxfb_dh_restore()
90 if (minfo->outputs[1].mode != MATROXFB_OUTPUT_MODE_MONITOR) { in matroxfb_dh_restore()
98 } else if (minfo->outputs[0].src == MATROXFB_SRC_CRTC2) { in matroxfb_dh_restore()
102 if (minfo->outputs[0].src == MATROXFB_SRC_CRTC2) { in matroxfb_dh_restore()
105 if (mt->interlaced) { in matroxfb_dh_restore()
107 mt->VDisplay >>= 1; in matroxfb_dh_restore()
108 mt->VSyncStart >>= 1; in matroxfb_dh_restore()
109 mt->VSyncEnd >>= 1; in matroxfb_dh_restore()
110 mt->VTotal >>= 1; in matroxfb_dh_restore()
112 if ((mt->HTotal & 7) == 2) { in matroxfb_dh_restore()
114 mt->HTotal &= ~7; in matroxfb_dh_restore()
117 mga_outl(0x3C14, ((mt->HDisplay - 8) << 16) | (mt->HTotal - 8)); in matroxfb_dh_restore()
118 mga_outl(0x3C18, ((mt->HSyncEnd - 8) << 16) | (mt->HSyncStart - 8)); in matroxfb_dh_restore()
119 mga_outl(0x3C1C, ((mt->VDisplay - 1) << 16) | (mt->VTotal - 1)); in matroxfb_dh_restore()
120 mga_outl(0x3C20, ((mt->VSyncEnd - 1) << 16) | (mt->VSyncStart - 1)); in matroxfb_dh_restore()
121 mga_outl(0x3C24, ((mt->VSyncStart) << 16) | (mt->HSyncStart)); /* preload */ in matroxfb_dh_restore()
123 u_int32_t linelen = m2info->fbcon.var.xres_virtual * (m2info->fbcon.var.bits_per_pixel >> 3); in matroxfb_dh_restore()
129 m2info->interlaced = 1; in matroxfb_dh_restore()
132 m2info->interlaced = 0; in matroxfb_dh_restore()
151 minfo->hw.crtc2.ctl = tmp; in matroxfb_dh_restore()
153 tmp = mt->VDisplay << 16; /* line compare */ in matroxfb_dh_restore()
154 if (mt->sync & FB_SYNC_HOR_HIGH_ACT) in matroxfb_dh_restore()
156 if (mt->sync & FB_SYNC_VERT_HIGH_ACT) in matroxfb_dh_restore()
162 struct matrox_fb_info *minfo = m2info->primary_dev; in matroxfb_dh_disable()
164 mga_outl(0x3C10, 0x00000004); /* disable CRTC2, CRTC1->DAC1, PLL as clock source */ in matroxfb_dh_disable()
165 minfo->hw.crtc2.ctl = 0x00000004; in matroxfb_dh_disable()
173 struct matrox_fb_info *minfo = m2info->primary_dev; in matroxfb_dh_pan_var()
175 m2info->fbcon.var.xoffset = var->xoffset; in matroxfb_dh_pan_var()
176 m2info->fbcon.var.yoffset = var->yoffset; in matroxfb_dh_pan_var()
177 pixelsize = m2info->fbcon.var.bits_per_pixel >> 3; in matroxfb_dh_pan_var()
178 linelen = m2info->fbcon.var.xres_virtual * pixelsize; in matroxfb_dh_pan_var()
179 pos = m2info->fbcon.var.yoffset * linelen + m2info->fbcon.var.xoffset * pixelsize; in matroxfb_dh_pan_var()
180 pos += m2info->video.offbase; in matroxfb_dh_pan_var()
181 if (m2info->interlaced) { in matroxfb_dh_pan_var()
198 switch (var->bits_per_pixel) { in matroxfb_dh_decode_var()
203 default: return -EINVAL; in matroxfb_dh_decode_var()
205 vramlen = m2info->video.len_usable; in matroxfb_dh_decode_var()
206 if (var->yres_virtual < var->yres) in matroxfb_dh_decode_var()
207 var->yres_virtual = var->yres; in matroxfb_dh_decode_var()
208 if (var->xres_virtual < var->xres) in matroxfb_dh_decode_var()
209 var->xres_virtual = var->xres; in matroxfb_dh_decode_var()
210 var->xres_virtual = (var->xres_virtual + mask) & ~mask; in matroxfb_dh_decode_var()
211 if (var->yres_virtual > 32767) in matroxfb_dh_decode_var()
212 return -EINVAL; in matroxfb_dh_decode_var()
213 memlen = var->xres_virtual * var->yres_virtual * (var->bits_per_pixel >> 3); in matroxfb_dh_decode_var()
215 return -EINVAL; in matroxfb_dh_decode_var()
216 if (var->xoffset + var->xres > var->xres_virtual) in matroxfb_dh_decode_var()
217 var->xoffset = var->xres_virtual - var->xres; in matroxfb_dh_decode_var()
218 if (var->yoffset + var->yres > var->yres_virtual) in matroxfb_dh_decode_var()
219 var->yoffset = var->yres_virtual - var->yres; in matroxfb_dh_decode_var()
221 var->xres &= ~7; in matroxfb_dh_decode_var()
222 var->left_margin &= ~7; in matroxfb_dh_decode_var()
223 var->right_margin &= ~7; in matroxfb_dh_decode_var()
224 var->hsync_len &= ~7; in matroxfb_dh_decode_var()
226 *mode = var->bits_per_pixel; in matroxfb_dh_decode_var()
227 if (var->bits_per_pixel == 16) { in matroxfb_dh_decode_var()
228 if (var->green.length == 5) { in matroxfb_dh_decode_var()
229 var->red.offset = 10; in matroxfb_dh_decode_var()
230 var->red.length = 5; in matroxfb_dh_decode_var()
231 var->green.offset = 5; in matroxfb_dh_decode_var()
232 var->green.length = 5; in matroxfb_dh_decode_var()
233 var->blue.offset = 0; in matroxfb_dh_decode_var()
234 var->blue.length = 5; in matroxfb_dh_decode_var()
235 var->transp.offset = 15; in matroxfb_dh_decode_var()
236 var->transp.length = 1; in matroxfb_dh_decode_var()
239 var->red.offset = 11; in matroxfb_dh_decode_var()
240 var->red.length = 5; in matroxfb_dh_decode_var()
241 var->green.offset = 5; in matroxfb_dh_decode_var()
242 var->green.length = 6; in matroxfb_dh_decode_var()
243 var->blue.offset = 0; in matroxfb_dh_decode_var()
244 var->blue.length = 5; in matroxfb_dh_decode_var()
245 var->transp.offset = 0; in matroxfb_dh_decode_var()
246 var->transp.length = 0; in matroxfb_dh_decode_var()
249 var->red.offset = 16; in matroxfb_dh_decode_var()
250 var->red.length = 8; in matroxfb_dh_decode_var()
251 var->green.offset = 8; in matroxfb_dh_decode_var()
252 var->green.length = 8; in matroxfb_dh_decode_var()
253 var->blue.offset = 0; in matroxfb_dh_decode_var()
254 var->blue.length = 8; in matroxfb_dh_decode_var()
255 var->transp.offset = 24; in matroxfb_dh_decode_var()
256 var->transp.length = 8; in matroxfb_dh_decode_var()
265 struct matrox_fb_info *minfo = m2info->primary_dev; in matroxfb_dh_open()
270 if (minfo->dead) { in matroxfb_dh_open()
271 return -ENXIO; in matroxfb_dh_open()
273 err = minfo->fbops.fb_open(&minfo->fbcon, user); in matroxfb_dh_open()
285 struct matrox_fb_info *minfo = m2info->primary_dev; in matroxfb_dh_release()
288 err = minfo->fbops.fb_release(&minfo->fbcon, user); in matroxfb_dh_release()
300 struct fb_fix_screeninfo *fix = &m2info->fbcon.fix; in matroxfb_dh_init_fix()
302 strcpy(fix->id, "MATROX DH"); in matroxfb_dh_init_fix()
304 fix->smem_start = m2info->video.base; in matroxfb_dh_init_fix()
305 fix->smem_len = m2info->video.len_usable; in matroxfb_dh_init_fix()
306 fix->ypanstep = 1; in matroxfb_dh_init_fix()
307 fix->ywrapstep = 0; in matroxfb_dh_init_fix()
308 fix->xpanstep = 8; /* TBD */ in matroxfb_dh_init_fix()
309 fix->mmio_start = m2info->mmio.base; in matroxfb_dh_init_fix()
310 fix->mmio_len = m2info->mmio.len; in matroxfb_dh_init_fix()
311 fix->accel = 0; /* no accel... */ in matroxfb_dh_init_fix()
330 struct fb_var_screeninfo* var = &info->var; in matroxfb_dh_set_par()
331 struct matrox_fb_info *minfo = m2info->primary_dev; in matroxfb_dh_set_par()
337 m2info->fbcon.screen_base = vaddr_va(m2info->video.vbase); in matroxfb_dh_set_par()
338 m2info->fbcon.fix.visual = visual; in matroxfb_dh_set_par()
339 m2info->fbcon.fix.type = FB_TYPE_PACKED_PIXELS; in matroxfb_dh_set_par()
340 m2info->fbcon.fix.type_aux = 0; in matroxfb_dh_set_par()
341 m2info->fbcon.fix.line_length = (var->xres_virtual * var->bits_per_pixel) >> 3; in matroxfb_dh_set_par()
349 matroxfb_var2my(&m2info->fbcon.var, &mt); in matroxfb_dh_set_par()
354 …pos = (m2info->fbcon.var.yoffset * m2info->fbcon.var.xres_virtual + m2info->fbcon.var.xoffset) * m… in matroxfb_dh_set_par()
355 pos += m2info->video.offbase; in matroxfb_dh_set_par()
357 down_read(&minfo->altout.lock); in matroxfb_dh_set_par()
359 if (minfo->outputs[out].src == MATROXFB_SRC_CRTC2) { in matroxfb_dh_set_par()
361 if (minfo->outputs[out].output->compute) { in matroxfb_dh_set_par()
362 minfo->outputs[out].output->compute(minfo->outputs[out].data, &mt); in matroxfb_dh_set_par()
366 minfo->crtc2.pixclock = mt.pixclock; in matroxfb_dh_set_par()
367 minfo->crtc2.mnp = mt.mnp; in matroxfb_dh_set_par()
368 up_read(&minfo->altout.lock); in matroxfb_dh_set_par()
376 down_read(&minfo->altout.lock); in matroxfb_dh_set_par()
378 if (minfo->outputs[out].src == MATROXFB_SRC_CRTC2 && in matroxfb_dh_set_par()
379 minfo->outputs[out].output->program) { in matroxfb_dh_set_par()
380 minfo->outputs[out].output->program(minfo->outputs[out].data); in matroxfb_dh_set_par()
384 if (minfo->outputs[out].src == MATROXFB_SRC_CRTC2 && in matroxfb_dh_set_par()
385 minfo->outputs[out].output->start) { in matroxfb_dh_set_par()
386 minfo->outputs[out].output->start(minfo->outputs[out].data); in matroxfb_dh_set_par()
389 up_read(&minfo->altout.lock); in matroxfb_dh_set_par()
391 m2info->initialized = 1; in matroxfb_dh_set_par()
404 struct matrox_fb_info *minfo = m2info->primary_dev; in matroxfb_dh_get_vblank()
408 vblank->flags = FB_VBLANK_HAVE_VCOUNT | FB_VBLANK_HAVE_VBLANK; in matroxfb_dh_get_vblank()
410 vblank->vcount = mga_inl(0x3C48) & 0x000007FF; in matroxfb_dh_get_vblank()
412 if (vblank->vcount >= m2info->fbcon.var.yres) in matroxfb_dh_get_vblank()
413 vblank->flags |= FB_VBLANK_VBLANKING; in matroxfb_dh_get_vblank()
414 if (test_bit(0, &minfo->irq_flags)) { in matroxfb_dh_get_vblank()
415 vblank->flags |= FB_VBLANK_HAVE_COUNT; in matroxfb_dh_get_vblank()
418 vblank->count = minfo->crtc2.vsync.cnt; in matroxfb_dh_get_vblank()
428 struct matrox_fb_info *minfo = m2info->primary_dev; in matroxfb_dh_ioctl()
442 return -EFAULT; in matroxfb_dh_ioctl()
450 return -EFAULT; in matroxfb_dh_ioctl()
453 return -ENODEV; in matroxfb_dh_ioctl()
460 return minfo->fbcon.fbops->fb_ioctl(&minfo->fbcon, cmd, arg); in matroxfb_dh_ioctl()
469 return -EFAULT; in matroxfb_dh_ioctl()
473 return -ENXIO; in matroxfb_dh_ioctl()
474 if (!minfo->outputs[out].output) in matroxfb_dh_ioctl()
475 return -ENXIO; in matroxfb_dh_ioctl()
476 switch (minfo->outputs[out].src) { in matroxfb_dh_ioctl()
481 return -EBUSY; in matroxfb_dh_ioctl()
485 if (minfo->devflags.panellink) { in matroxfb_dh_ioctl()
487 return -EINVAL; in matroxfb_dh_ioctl()
488 if ((minfo->outputs[2].src == MATROXFB_SRC_CRTC1) && tmp) in matroxfb_dh_ioctl()
489 return -EBUSY; in matroxfb_dh_ioctl()
494 if (minfo->outputs[out].src != MATROXFB_SRC_CRTC2) { in matroxfb_dh_ioctl()
496 minfo->outputs[out].src = MATROXFB_SRC_CRTC2; in matroxfb_dh_ioctl()
498 } else if (minfo->outputs[out].src == MATROXFB_SRC_CRTC2) { in matroxfb_dh_ioctl()
500 minfo->outputs[out].src = MATROXFB_SRC_NONE; in matroxfb_dh_ioctl()
514 if (minfo->outputs[out].src == MATROXFB_SRC_CRTC2) { in matroxfb_dh_ioctl()
519 return -EFAULT; in matroxfb_dh_ioctl()
528 if (minfo->outputs[out].output) { in matroxfb_dh_ioctl()
529 switch (minfo->outputs[out].src) { in matroxfb_dh_ioctl()
537 if (minfo->devflags.panellink) { in matroxfb_dh_ioctl()
539 if (minfo->outputs[2].src == MATROXFB_SRC_CRTC1) { in matroxfb_dh_ioctl()
544 return -EFAULT; in matroxfb_dh_ioctl()
548 return -ENOTTY; in matroxfb_dh_ioctl()
583 0,0, /* offset */
592 -1,-1, /* display size */
602 #define minfo (m2info->primary_dev) in matroxfb_dh_regit()
605 m2info->fbcon.fbops = &matroxfb_dh_ops; in matroxfb_dh_regit()
606 m2info->fbcon.flags = FBINFO_FLAG_DEFAULT; in matroxfb_dh_regit()
607 m2info->fbcon.flags |= FBINFO_HWACCEL_XPAN | in matroxfb_dh_regit()
609 m2info->fbcon.pseudo_palette = m2info->cmap; in matroxfb_dh_regit()
610 fb_alloc_cmap(&m2info->fbcon.cmap, 256, 1); in matroxfb_dh_regit()
617 if (minfo->video.len_usable + mem <= minfo->video.len) in matroxfb_dh_regit()
618 m2info->video.offbase = minfo->video.len - mem; in matroxfb_dh_regit()
619 else if (minfo->video.len < mem) { in matroxfb_dh_regit()
620 return -ENOMEM; in matroxfb_dh_regit()
622 m2info->video.borrowed = mem; in matroxfb_dh_regit()
623 minfo->video.len_usable -= mem; in matroxfb_dh_regit()
624 m2info->video.offbase = minfo->video.len_usable; in matroxfb_dh_regit()
626 m2info->video.base = minfo->video.base + m2info->video.offbase; in matroxfb_dh_regit()
627 m2info->video.len = m2info->video.len_usable = m2info->video.len_maximum = mem; in matroxfb_dh_regit()
628 m2info->video.vbase.vaddr = vaddr_va(minfo->video.vbase) + m2info->video.offbase; in matroxfb_dh_regit()
629 m2info->mmio.base = minfo->mmio.base; in matroxfb_dh_regit()
630 m2info->mmio.vbase = minfo->mmio.vbase; in matroxfb_dh_regit()
631 m2info->mmio.len = minfo->mmio.len; in matroxfb_dh_regit()
634 if (register_framebuffer(&m2info->fbcon)) { in matroxfb_dh_regit()
635 return -ENXIO; in matroxfb_dh_regit()
637 if (!m2info->initialized) in matroxfb_dh_regit()
638 fb_set_var(&m2info->fbcon, &matroxfb_dh_defined); in matroxfb_dh_regit()
639 down_write(&minfo->crtc2.lock); in matroxfb_dh_regit()
640 oldcrtc2 = minfo->crtc2.info; in matroxfb_dh_regit()
641 minfo->crtc2.info = m2info; in matroxfb_dh_regit()
642 up_write(&minfo->crtc2.lock); in matroxfb_dh_regit()
654 #define minfo (m2info->primary_dev) in matroxfb_dh_registerfb()
657 return -1; in matroxfb_dh_registerfb()
660 minfo->fbcon.node, m2info->fbcon.node); in matroxfb_dh_registerfb()
661 m2info->fbcon_registered = 1; in matroxfb_dh_registerfb()
667 #define minfo (m2info->primary_dev) in matroxfb_dh_deregisterfb()
668 if (m2info->fbcon_registered) { in matroxfb_dh_deregisterfb()
672 down_write(&minfo->crtc2.lock); in matroxfb_dh_deregisterfb()
673 crtc2 = minfo->crtc2.info; in matroxfb_dh_deregisterfb()
675 minfo->crtc2.info = NULL; in matroxfb_dh_deregisterfb()
676 up_write(&minfo->crtc2.lock); in matroxfb_dh_deregisterfb()
683 id = m2info->fbcon.node; in matroxfb_dh_deregisterfb()
684 unregister_framebuffer(&m2info->fbcon); in matroxfb_dh_deregisterfb()
686 minfo->video.len_usable += m2info->video.borrowed; in matroxfb_dh_deregisterfb()
688 m2info->fbcon_registered = 0; in matroxfb_dh_deregisterfb()
697 if (!minfo->devflags.crtc2) in matroxfb_crtc2_probe()
703 m2info->primary_dev = minfo; in matroxfb_crtc2_probe()
724 return -ENODEV; in matroxfb_crtc2_init()
734 MODULE_AUTHOR("(c) 1999-2002 Petr Vandrovec <vandrove@vc.cvut.cz>");