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

1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright 2012-2019 Red Hat
14 * drivers/video/cirrusfb.c - driver for Cirrus Logic chipsets
16 * Copyright 1999-2001 Jeff Garzik <jgarzik@pobox.com>
19 #include <linux/iosys-map.h>
24 #include <video/vga.h>
49 #define DRIVER_DESC "qemu cirrus vga"
54 #define CIRRUS_MAX_PITCH (0x1FF << 3) /* (4096 - 1) & ~111b bytes */
77 const struct drm_format_info *format; member
87 /* ------------------------------------------------------------------ */
102 iowrite8(reg, cirrus->mmio + SEQ_INDEX); in rreg_seq()
103 return ioread8(cirrus->mmio + SEQ_DATA); in rreg_seq()
108 iowrite8(reg, cirrus->mmio + SEQ_INDEX); in wreg_seq()
109 iowrite8(val, cirrus->mmio + SEQ_DATA); in wreg_seq()
117 iowrite8(reg, cirrus->mmio + CRT_INDEX); in rreg_crt()
118 return ioread8(cirrus->mmio + CRT_DATA); in rreg_crt()
123 iowrite8(reg, cirrus->mmio + CRT_INDEX); in wreg_crt()
124 iowrite8(val, cirrus->mmio + CRT_DATA); in wreg_crt()
132 iowrite8(reg, cirrus->mmio + GFX_INDEX); in wreg_gfx()
133 iowrite8(val, cirrus->mmio + GFX_DATA); in wreg_gfx()
140 ioread8(cirrus->mmio + VGA_DAC_MASK); in wreg_hdr()
141 ioread8(cirrus->mmio + VGA_DAC_MASK); in wreg_hdr()
142 ioread8(cirrus->mmio + VGA_DAC_MASK); in wreg_hdr()
143 ioread8(cirrus->mmio + VGA_DAC_MASK); in wreg_hdr()
144 iowrite8(val, cirrus->mmio + VGA_DAC_MASK); in wreg_hdr()
149 if (fb->format->format == DRM_FORMAT_XRGB8888 && fb->pitches[0] > CIRRUS_MAX_PITCH) { in cirrus_convert_to()
150 if (fb->width * 3 <= CIRRUS_MAX_PITCH) in cirrus_convert_to()
162 const struct drm_format_info *format = cirrus_convert_to(fb); in cirrus_format() local
164 if (format) in cirrus_format()
165 return format; in cirrus_format()
166 return fb->format; in cirrus_format()
171 const struct drm_format_info *format = cirrus_convert_to(fb); in cirrus_pitch() local
173 if (format) in cirrus_pitch()
174 return drm_format_info_min_pitch(format, 0, fb->width); in cirrus_pitch()
175 return fb->pitches[0]; in cirrus_pitch()
206 htotal = mode->htotal / 8; in cirrus_mode_set()
207 hsyncend = mode->hsync_end / 8; in cirrus_mode_set()
208 hsyncstart = mode->hsync_start / 8; in cirrus_mode_set()
209 hdispend = mode->hdisplay / 8; in cirrus_mode_set()
211 vtotal = mode->vtotal; in cirrus_mode_set()
212 vdispend = mode->vdisplay; in cirrus_mode_set()
214 vdispend -= 1; in cirrus_mode_set()
215 vtotal -= 2; in cirrus_mode_set()
217 htotal -= 5; in cirrus_mode_set()
218 hdispend -= 1; in cirrus_mode_set()
271 const struct drm_format_info *format) in cirrus_format_set() argument
278 switch (format->format) { in cirrus_format_set()
301 /* Enable high-colour modes */ in cirrus_format_set()
327 /* ------------------------------------------------------------------ */
347 struct drm_framebuffer *fb = new_plane_state->fb; in cirrus_primary_plane_helper_atomic_check()
348 struct drm_crtc *new_crtc = new_plane_state->crtc; in cirrus_primary_plane_helper_atomic_check()
362 else if (!new_plane_state->visible) in cirrus_primary_plane_helper_atomic_check()
369 return -EINVAL; in cirrus_primary_plane_helper_atomic_check()
370 else if (pitch * fb->height > CIRRUS_VRAM_SIZE) in cirrus_primary_plane_helper_atomic_check()
371 return -EINVAL; in cirrus_primary_plane_helper_atomic_check()
373 new_primary_plane_state->format = cirrus_format(fb); in cirrus_primary_plane_helper_atomic_check()
374 new_primary_plane_state->pitch = pitch; in cirrus_primary_plane_helper_atomic_check()
382 struct cirrus_device *cirrus = to_cirrus(plane->dev); in cirrus_primary_plane_helper_atomic_update()
387 struct drm_framebuffer *fb = plane_state->fb; in cirrus_primary_plane_helper_atomic_update()
388 const struct drm_format_info *format = primary_plane_state->format; in cirrus_primary_plane_helper_atomic_update() local
389 unsigned int pitch = primary_plane_state->pitch; in cirrus_primary_plane_helper_atomic_update()
393 struct iosys_map vaddr = IOSYS_MAP_INIT_VADDR_IOMEM(cirrus->vram); in cirrus_primary_plane_helper_atomic_update()
401 if (!drm_dev_enter(&cirrus->dev, &idx)) in cirrus_primary_plane_helper_atomic_update()
404 if (old_primary_plane_state->format != format) in cirrus_primary_plane_helper_atomic_update()
405 cirrus_format_set(cirrus, format); in cirrus_primary_plane_helper_atomic_update()
406 if (old_primary_plane_state->pitch != pitch) in cirrus_primary_plane_helper_atomic_update()
411 unsigned int offset = drm_fb_clip_offset(pitch, format, &damage); in cirrus_primary_plane_helper_atomic_update()
414 drm_fb_blit(&dst, &pitch, format->format, shadow_plane_state->data, fb, in cirrus_primary_plane_helper_atomic_update()
415 &damage, &shadow_plane_state->fmtcnv_state); in cirrus_primary_plane_helper_atomic_update()
430 struct drm_plane_state *plane_state = plane->state; in cirrus_primary_plane_atomic_duplicate_state()
442 new_shadow_plane_state = &new_primary_plane_state->base; in cirrus_primary_plane_atomic_duplicate_state()
445 new_primary_plane_state->format = primary_plane_state->format; in cirrus_primary_plane_atomic_duplicate_state()
446 new_primary_plane_state->pitch = primary_plane_state->pitch; in cirrus_primary_plane_atomic_duplicate_state()
448 return &new_shadow_plane_state->base; in cirrus_primary_plane_atomic_duplicate_state()
457 __drm_gem_destroy_shadow_plane_state(&primary_plane_state->base); in cirrus_primary_plane_atomic_destroy_state()
465 if (plane->state) { in cirrus_reset_primary_plane()
466 cirrus_primary_plane_atomic_destroy_state(plane, plane->state); in cirrus_reset_primary_plane()
467 plane->state = NULL; /* must be set to NULL here */ in cirrus_reset_primary_plane()
473 __drm_gem_reset_shadow_plane(plane, &primary_plane_state->base); in cirrus_reset_primary_plane()
490 if (!crtc_state->enable) in cirrus_crtc_helper_atomic_check()
503 struct cirrus_device *cirrus = to_cirrus(crtc->dev); in cirrus_crtc_helper_atomic_enable()
507 if (!drm_dev_enter(&cirrus->dev, &idx)) in cirrus_crtc_helper_atomic_enable()
510 cirrus_mode_set(cirrus, &crtc_state->mode); in cirrus_crtc_helper_atomic_enable()
541 connector->dev->mode_config.max_width, in cirrus_connector_helper_get_modes()
542 connector->dev->mode_config.max_height); in cirrus_connector_helper_get_modes()
561 struct drm_device *dev = &cirrus->dev; in cirrus_pipe_init()
568 primary_plane = &cirrus->primary_plane; in cirrus_pipe_init()
580 crtc = &cirrus->crtc; in cirrus_pipe_init()
587 encoder = &cirrus->encoder; in cirrus_pipe_init()
592 encoder->possible_crtcs = drm_crtc_mask(crtc); in cirrus_pipe_init()
594 connector = &cirrus->connector; in cirrus_pipe_init()
608 /* ------------------------------------------------------------------ */
614 const struct drm_format_info *format = drm_format_info(DRM_FORMAT_XRGB8888); in cirrus_mode_config_mode_valid() local
615 uint64_t pitch = drm_format_info_min_pitch(format, 0, mode->hdisplay); in cirrus_mode_config_mode_valid()
617 if (pitch * mode->vdisplay > CIRRUS_VRAM_SIZE) in cirrus_mode_config_mode_valid()
632 struct drm_device *dev = &cirrus->dev; in cirrus_mode_config_init()
639 dev->mode_config.min_width = 0; in cirrus_mode_config_init()
640 dev->mode_config.min_height = 0; in cirrus_mode_config_init()
641 dev->mode_config.max_width = CIRRUS_MAX_PITCH / 2; in cirrus_mode_config_init()
642 dev->mode_config.max_height = 1024; in cirrus_mode_config_init()
643 dev->mode_config.preferred_depth = 16; in cirrus_mode_config_init()
644 dev->mode_config.prefer_shadow = 0; in cirrus_mode_config_init()
645 dev->mode_config.funcs = &cirrus_mode_config_funcs; in cirrus_mode_config_init()
650 /* ------------------------------------------------------------------ */
686 ret = -ENOMEM; in cirrus_pci_probe()
687 cirrus = devm_drm_dev_alloc(&pdev->dev, &cirrus_driver, in cirrus_pci_probe()
692 dev = &cirrus->dev; in cirrus_pci_probe()
694 cirrus->vram = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 0), in cirrus_pci_probe()
696 if (cirrus->vram == NULL) in cirrus_pci_probe()
697 return -ENOMEM; in cirrus_pci_probe()
699 cirrus->mmio = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 1), in cirrus_pci_probe()
701 if (cirrus->mmio == NULL) in cirrus_pci_probe()
702 return -ENOMEM; in cirrus_pci_probe()