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 */
69 /* ------------------------------------------------------------------ */
84 iowrite8(reg, cirrus->mmio + SEQ_INDEX); in rreg_seq()
85 return ioread8(cirrus->mmio + SEQ_DATA); in rreg_seq()
90 iowrite8(reg, cirrus->mmio + SEQ_INDEX); in wreg_seq()
91 iowrite8(val, cirrus->mmio + SEQ_DATA); in wreg_seq()
99 iowrite8(reg, cirrus->mmio + CRT_INDEX); in rreg_crt()
100 return ioread8(cirrus->mmio + CRT_DATA); in rreg_crt()
105 iowrite8(reg, cirrus->mmio + CRT_INDEX); in wreg_crt()
106 iowrite8(val, cirrus->mmio + CRT_DATA); in wreg_crt()
114 iowrite8(reg, cirrus->mmio + GFX_INDEX); in wreg_gfx()
115 iowrite8(val, cirrus->mmio + GFX_DATA); in wreg_gfx()
122 ioread8(cirrus->mmio + VGA_DAC_MASK); in wreg_hdr()
123 ioread8(cirrus->mmio + VGA_DAC_MASK); in wreg_hdr()
124 ioread8(cirrus->mmio + VGA_DAC_MASK); in wreg_hdr()
125 ioread8(cirrus->mmio + VGA_DAC_MASK); in wreg_hdr()
126 iowrite8(val, cirrus->mmio + VGA_DAC_MASK); in wreg_hdr()
131 if (fb->format->cpp[0] == 4 && fb->pitches[0] > CIRRUS_MAX_PITCH) { in cirrus_convert_to()
132 if (fb->width * 3 <= CIRRUS_MAX_PITCH) in cirrus_convert_to()
148 return fb->format->cpp[0]; in cirrus_cpp()
156 return convert_cpp * fb->width; in cirrus_pitch()
157 return fb->pitches[0]; in cirrus_pitch()
166 if (!drm_dev_enter(&cirrus->dev, &idx)) in cirrus_set_start_address()
196 if (!drm_dev_enter(&cirrus->dev, &idx)) in cirrus_mode_set()
197 return -1; in cirrus_mode_set()
199 htotal = mode->htotal / 8; in cirrus_mode_set()
200 hsyncend = mode->hsync_end / 8; in cirrus_mode_set()
201 hsyncstart = mode->hsync_start / 8; in cirrus_mode_set()
202 hdispend = mode->hdisplay / 8; in cirrus_mode_set()
204 vtotal = mode->vtotal; in cirrus_mode_set()
205 vdispend = mode->vdisplay; in cirrus_mode_set()
207 vdispend -= 1; in cirrus_mode_set()
208 vtotal -= 2; in cirrus_mode_set()
210 htotal -= 5; in cirrus_mode_set()
211 hdispend -= 1; in cirrus_mode_set()
266 cirrus->cpp = cirrus_cpp(fb); in cirrus_mode_set()
267 switch (cirrus->cpp * 8) { in cirrus_mode_set()
285 return -1; in cirrus_mode_set()
291 cirrus->pitch = cirrus_pitch(fb); in cirrus_mode_set()
292 tmp = cirrus->pitch / 8; in cirrus_mode_set()
297 tmp |= (cirrus->pitch >> 7) & 0x10; in cirrus_mode_set()
298 tmp |= (cirrus->pitch >> 6) & 0x40; in cirrus_mode_set()
301 /* Enable high-colour modes */ in cirrus_mode_set()
322 struct cirrus_device *cirrus = to_cirrus(fb->dev); in cirrus_fb_blit_rect()
326 if (!drm_dev_enter(&cirrus->dev, &idx)) in cirrus_fb_blit_rect()
327 return -ENODEV; in cirrus_fb_blit_rect()
329 iosys_map_set_vaddr_iomem(&dst, cirrus->vram); in cirrus_fb_blit_rect()
331 if (cirrus->cpp == fb->format->cpp[0]) { in cirrus_fb_blit_rect()
332 iosys_map_incr(&dst, drm_fb_clip_offset(fb->pitches[0], fb->format, rect)); in cirrus_fb_blit_rect()
333 drm_fb_memcpy(&dst, fb->pitches, vmap, fb, rect); in cirrus_fb_blit_rect()
335 } else if (fb->format->cpp[0] == 4 && cirrus->cpp == 2) { in cirrus_fb_blit_rect()
336 iosys_map_incr(&dst, drm_fb_clip_offset(cirrus->pitch, fb->format, rect)); in cirrus_fb_blit_rect()
337 drm_fb_xrgb8888_to_rgb565(&dst, &cirrus->pitch, vmap, fb, rect, false); in cirrus_fb_blit_rect()
339 } else if (fb->format->cpp[0] == 4 && cirrus->cpp == 3) { in cirrus_fb_blit_rect()
340 iosys_map_incr(&dst, drm_fb_clip_offset(cirrus->pitch, fb->format, rect)); in cirrus_fb_blit_rect()
341 drm_fb_xrgb8888_to_rgb888(&dst, &cirrus->pitch, vmap, fb, rect); in cirrus_fb_blit_rect()
357 .x2 = fb->width, in cirrus_fb_blit_fullscreen()
359 .y2 = fb->height, in cirrus_fb_blit_fullscreen()
373 return -EINVAL; in cirrus_check_size()
375 return -EINVAL; in cirrus_check_size()
379 /* ------------------------------------------------------------------ */
387 conn->dev->mode_config.max_width, in cirrus_conn_get_modes()
388 conn->dev->mode_config.max_height); in cirrus_conn_get_modes()
407 drm_connector_helper_add(&cirrus->conn, &cirrus_conn_helper_funcs); in cirrus_conn_init()
408 return drm_connector_init(&cirrus->dev, &cirrus->conn, in cirrus_conn_init()
413 /* ------------------------------------------------------------------ */
419 if (cirrus_check_size(mode->hdisplay, mode->vdisplay, NULL) < 0) in cirrus_pipe_mode_valid()
428 struct drm_framebuffer *fb = plane_state->fb; in cirrus_pipe_check()
432 return cirrus_check_size(fb->width, fb->height, fb); in cirrus_pipe_check()
439 struct cirrus_device *cirrus = to_cirrus(pipe->crtc.dev); in cirrus_pipe_enable()
442 cirrus_mode_set(cirrus, &crtc_state->mode, plane_state->fb); in cirrus_pipe_enable()
443 cirrus_fb_blit_fullscreen(plane_state->fb, &shadow_plane_state->data[0]); in cirrus_pipe_enable()
449 struct cirrus_device *cirrus = to_cirrus(pipe->crtc.dev); in cirrus_pipe_update()
450 struct drm_plane_state *state = pipe->plane.state; in cirrus_pipe_update()
452 struct drm_crtc *crtc = &pipe->crtc; in cirrus_pipe_update()
455 if (state->fb && cirrus->cpp != cirrus_cpp(state->fb)) in cirrus_pipe_update()
456 cirrus_mode_set(cirrus, &crtc->mode, state->fb); in cirrus_pipe_update()
459 cirrus_fb_blit_rect(state->fb, &shadow_plane_state->data[0], &rect); in cirrus_pipe_update()
483 return drm_simple_display_pipe_init(&cirrus->dev, in cirrus_pipe_init()
484 &cirrus->pipe, in cirrus_pipe_init()
489 &cirrus->conn); in cirrus_pipe_init()
492 /* ------------------------------------------------------------------ */
499 if (mode_cmd->pixel_format != DRM_FORMAT_RGB565 && in cirrus_fb_create()
500 mode_cmd->pixel_format != DRM_FORMAT_RGB888 && in cirrus_fb_create()
501 mode_cmd->pixel_format != DRM_FORMAT_XRGB8888) in cirrus_fb_create()
502 return ERR_PTR(-EINVAL); in cirrus_fb_create()
503 if (cirrus_check_size(mode_cmd->width, mode_cmd->height, NULL) < 0) in cirrus_fb_create()
504 return ERR_PTR(-EINVAL); in cirrus_fb_create()
516 struct drm_device *dev = &cirrus->dev; in cirrus_mode_config_init()
523 dev->mode_config.min_width = 0; in cirrus_mode_config_init()
524 dev->mode_config.min_height = 0; in cirrus_mode_config_init()
525 dev->mode_config.max_width = CIRRUS_MAX_PITCH / 2; in cirrus_mode_config_init()
526 dev->mode_config.max_height = 1024; in cirrus_mode_config_init()
527 dev->mode_config.preferred_depth = 16; in cirrus_mode_config_init()
528 dev->mode_config.prefer_shadow = 0; in cirrus_mode_config_init()
529 dev->mode_config.funcs = &cirrus_mode_config_funcs; in cirrus_mode_config_init()
534 /* ------------------------------------------------------------------ */
570 ret = -ENOMEM; in cirrus_pci_probe()
571 cirrus = devm_drm_dev_alloc(&pdev->dev, &cirrus_driver, in cirrus_pci_probe()
576 dev = &cirrus->dev; in cirrus_pci_probe()
578 cirrus->vram = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 0), in cirrus_pci_probe()
580 if (cirrus->vram == NULL) in cirrus_pci_probe()
581 return -ENOMEM; in cirrus_pci_probe()
583 cirrus->mmio = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 1), in cirrus_pci_probe()
585 if (cirrus->mmio == NULL) in cirrus_pci_probe()
586 return -ENOMEM; in cirrus_pci_probe()
607 drm_fbdev_generic_setup(dev, dev->mode_config.preferred_depth); in cirrus_pci_probe()