Lines Matching +full:vga +full:- +full:format

1 // SPDX-License-Identifier: GPL-2.0-or-later
20 #include <video/vga.h>
22 /* ---------------------------------------------------------------------- */
53 static int bochs_modeset = -1;
65 /* ---------------------------------------------------------------------- */
96 /* ---------------------------------------------------------------------- */
103 if (bochs->mmio) { in bochs_vga_writeb()
104 int offset = ioport - 0x3c0 + 0x400; in bochs_vga_writeb()
106 writeb(val, bochs->mmio + offset); in bochs_vga_writeb()
117 if (bochs->mmio) { in bochs_vga_readb()
118 int offset = ioport - 0x3c0 + 0x400; in bochs_vga_readb()
120 return readb(bochs->mmio + offset); in bochs_vga_readb()
130 if (bochs->mmio) { in bochs_dispi_read()
133 ret = readw(bochs->mmio + offset); in bochs_dispi_read()
143 if (bochs->mmio) { in bochs_dispi_write()
146 writew(val, bochs->mmio + offset); in bochs_dispi_write()
155 if (bochs->qext_size < 8) in bochs_hw_set_big_endian()
158 writel(0xbebebebe, bochs->mmio + 0x604); in bochs_hw_set_big_endian()
163 if (bochs->qext_size < 8) in bochs_hw_set_little_endian()
166 writel(0x1e1e1e1e, bochs->mmio + 0x604); in bochs_hw_set_little_endian()
181 if (start + len > 0x400 /* vga register offset */) in bochs_get_edid_block()
182 return -1; in bochs_get_edid_block()
185 buf[i] = readb(bochs->mmio + start + i); in bochs_get_edid_block()
194 if (!bochs->mmio) in bochs_hw_load_edid()
195 return -1; in bochs_hw_load_edid()
200 return -1; in bochs_hw_load_edid()
202 drm_edid_free(bochs->drm_edid); in bochs_hw_load_edid()
203 bochs->drm_edid = drm_edid_read_custom(&bochs->connector, in bochs_hw_load_edid()
205 if (!bochs->drm_edid) in bochs_hw_load_edid()
206 return -1; in bochs_hw_load_edid()
213 struct bochs_device *bochs = dev->dev_private; in bochs_hw_init()
214 struct pci_dev *pdev = to_pci_dev(dev->dev); in bochs_hw_init()
218 if (pdev->resource[2].flags & IORESOURCE_MEM) { in bochs_hw_init()
219 /* mmio bar with vga and bochs registers present */ in bochs_hw_init()
220 if (pci_request_region(pdev, 2, "bochs-drm") != 0) { in bochs_hw_init()
222 return -EBUSY; in bochs_hw_init()
226 bochs->mmio = ioremap(ioaddr, iosize); in bochs_hw_init()
227 if (bochs->mmio == NULL) { in bochs_hw_init()
229 return -ENOMEM; in bochs_hw_init()
234 if (!request_region(ioaddr, iosize, "bochs-drm")) { in bochs_hw_init()
236 return -EBUSY; in bochs_hw_init()
238 bochs->ioports = 1; in bochs_hw_init()
246 return -ENODEV; in bochs_hw_init()
249 if ((pdev->resource[0].flags & IORESOURCE_MEM) == 0) in bochs_hw_init()
250 return -ENODEV; in bochs_hw_init()
254 return -ENODEV; in bochs_hw_init()
261 if (pci_request_region(pdev, 0, "bochs-drm") != 0) in bochs_hw_init()
264 bochs->fb_map = ioremap(addr, size); in bochs_hw_init()
265 if (bochs->fb_map == NULL) { in bochs_hw_init()
267 return -ENOMEM; in bochs_hw_init()
269 bochs->fb_base = addr; in bochs_hw_init()
270 bochs->fb_size = size; in bochs_hw_init()
272 DRM_INFO("Found bochs VGA, ID 0x%x.\n", id); in bochs_hw_init()
275 bochs->ioports ? "ioports" : "mmio", in bochs_hw_init()
278 if (bochs->mmio && pdev->revision >= 2) { in bochs_hw_init()
279 bochs->qext_size = readl(bochs->mmio + 0x600); in bochs_hw_init()
280 if (bochs->qext_size < 4 || bochs->qext_size > iosize) { in bochs_hw_init()
281 bochs->qext_size = 0; in bochs_hw_init()
285 bochs->qext_size); in bochs_hw_init()
295 struct bochs_device *bochs = dev->dev_private; in bochs_hw_fini()
299 if (bochs->mmio) in bochs_hw_fini()
300 iounmap(bochs->mmio); in bochs_hw_fini()
301 if (bochs->ioports) in bochs_hw_fini()
303 if (bochs->fb_map) in bochs_hw_fini()
304 iounmap(bochs->fb_map); in bochs_hw_fini()
305 pci_release_regions(to_pci_dev(dev->dev)); in bochs_hw_fini()
306 drm_edid_free(bochs->drm_edid); in bochs_hw_fini()
324 if (!drm_dev_enter(bochs->dev, &idx)) in bochs_hw_setmode()
327 bochs->xres = mode->hdisplay; in bochs_hw_setmode()
328 bochs->yres = mode->vdisplay; in bochs_hw_setmode()
329 bochs->bpp = 32; in bochs_hw_setmode()
330 bochs->stride = mode->hdisplay * (bochs->bpp / 8); in bochs_hw_setmode()
331 bochs->yres_virtual = bochs->fb_size / bochs->stride; in bochs_hw_setmode()
334 bochs->xres, bochs->yres, bochs->bpp, in bochs_hw_setmode()
335 bochs->yres_virtual); in bochs_hw_setmode()
340 bochs_dispi_write(bochs, VBE_DISPI_INDEX_BPP, bochs->bpp); in bochs_hw_setmode()
341 bochs_dispi_write(bochs, VBE_DISPI_INDEX_XRES, bochs->xres); in bochs_hw_setmode()
342 bochs_dispi_write(bochs, VBE_DISPI_INDEX_YRES, bochs->yres); in bochs_hw_setmode()
344 bochs_dispi_write(bochs, VBE_DISPI_INDEX_VIRT_WIDTH, bochs->xres); in bochs_hw_setmode()
346 bochs->yres_virtual); in bochs_hw_setmode()
356 static void bochs_hw_setformat(struct bochs_device *bochs, const struct drm_format_info *format) in bochs_hw_setformat() argument
360 if (!drm_dev_enter(bochs->dev, &idx)) in bochs_hw_setformat()
363 DRM_DEBUG_DRIVER("format %c%c%c%c\n", in bochs_hw_setformat()
364 (format->format >> 0) & 0xff, in bochs_hw_setformat()
365 (format->format >> 8) & 0xff, in bochs_hw_setformat()
366 (format->format >> 16) & 0xff, in bochs_hw_setformat()
367 (format->format >> 24) & 0xff); in bochs_hw_setformat()
369 switch (format->format) { in bochs_hw_setformat()
378 DRM_ERROR("%s: Huh? Got framebuffer format 0x%x", in bochs_hw_setformat()
379 __func__, format->format); in bochs_hw_setformat()
391 if (!drm_dev_enter(bochs->dev, &idx)) in bochs_hw_setbase()
394 bochs->stride = stride; in bochs_hw_setbase()
396 y * bochs->stride + in bochs_hw_setbase()
397 x * (bochs->bpp / 8); in bochs_hw_setbase()
398 vy = offset / bochs->stride; in bochs_hw_setbase()
399 vx = (offset % bochs->stride) * 8 / bochs->bpp; in bochs_hw_setbase()
400 vwidth = stride * 8 / bochs->bpp; in bochs_hw_setbase()
402 DRM_DEBUG_DRIVER("x %d, y %d, addr %llx -> offset %lx, vx %d, vy %d\n", in bochs_hw_setbase()
411 /* ---------------------------------------------------------------------- */
423 if (!state->fb || !bochs->stride) in bochs_plane_update()
426 gbo = drm_gem_vram_of_gem(state->fb->obj[0]); in bochs_plane_update()
432 state->crtc_x, in bochs_plane_update()
433 state->crtc_y, in bochs_plane_update()
434 state->fb->pitches[0], in bochs_plane_update()
435 state->fb->offsets[0] + gpu_addr); in bochs_plane_update()
436 bochs_hw_setformat(bochs, state->fb->format); in bochs_plane_update()
443 struct bochs_device *bochs = pipe->crtc.dev->dev_private; in bochs_pipe_enable()
445 bochs_hw_setmode(bochs, &crtc_state->mode); in bochs_pipe_enable()
451 struct bochs_device *bochs = pipe->crtc.dev->dev_private; in bochs_pipe_disable()
459 struct bochs_device *bochs = pipe->crtc.dev->dev_private; in bochs_pipe_update()
461 bochs_plane_update(bochs, pipe->plane.state); in bochs_pipe_update()
499 struct bochs_device *bochs = dev->dev_private; in bochs_connector_init()
500 struct drm_connector *connector = &bochs->connector; in bochs_connector_init()
507 if (bochs->drm_edid) { in bochs_connector_init()
510 drm_edid_connector_update(&bochs->connector, bochs->drm_edid); in bochs_connector_init()
518 if (mode_cmd->pixel_format != DRM_FORMAT_XRGB8888 && in bochs_gem_fb_create()
519 mode_cmd->pixel_format != DRM_FORMAT_BGRX8888) in bochs_gem_fb_create()
520 return ERR_PTR(-EINVAL); in bochs_gem_fb_create()
536 ret = drmm_mode_config_init(bochs->dev); in bochs_kms_init()
540 bochs->dev->mode_config.max_width = 8192; in bochs_kms_init()
541 bochs->dev->mode_config.max_height = 8192; in bochs_kms_init()
543 bochs->dev->mode_config.preferred_depth = 24; in bochs_kms_init()
544 bochs->dev->mode_config.prefer_shadow = 0; in bochs_kms_init()
545 bochs->dev->mode_config.quirk_addfb_prefer_host_byte_order = true; in bochs_kms_init()
547 bochs->dev->mode_config.funcs = &bochs_mode_funcs; in bochs_kms_init()
549 bochs_connector_init(bochs->dev); in bochs_kms_init()
550 drm_simple_display_pipe_init(bochs->dev, in bochs_kms_init()
551 &bochs->pipe, in bochs_kms_init()
556 &bochs->connector); in bochs_kms_init()
558 drm_mode_config_reset(bochs->dev); in bochs_kms_init()
563 /* ---------------------------------------------------------------------- */
573 return -ENOMEM; in bochs_load()
574 dev->dev_private = bochs; in bochs_load()
575 bochs->dev = dev; in bochs_load()
581 ret = drmm_vram_helper_init(dev, bochs->fb_base, bochs->fb_size); in bochs_load()
601 .name = "bochs-drm",
602 .desc = "bochs dispi vga interface (qemu stdvga)",
609 /* ---------------------------------------------------------------------- */
633 /* ---------------------------------------------------------------------- */
645 return -ENOMEM; in bochs_pci_probe()
652 dev = drm_dev_alloc(&bochs_driver, &pdev->dev); in bochs_pci_probe()
721 .name = "bochs-drm",
729 /* ---------------------------------------------------------------------- */
736 MODULE_DESCRIPTION("DRM Support for bochs dispi vga interface (qemu stdvga)");