[openchrome-devel] drm-openchrome: Branch 'drm-next-5.5' - 5 commits - drivers/gpu/drm
Kevin Brace
kevinbrace at kemper.freedesktop.org
Fri Oct 18 16:16:27 UTC 2019
drivers/gpu/drm/openchrome/openchrome_crtc.c | 341 +++++++++++-------------
drivers/gpu/drm/openchrome/openchrome_display.h | 213 --------------
drivers/gpu/drm/openchrome/openchrome_drv.h | 185 ++++++++++++-
3 files changed, 348 insertions(+), 391 deletions(-)
New commits:
commit a2dc9d30e7a1e0c60f3e5814b18d17a769a76ed3
Author: Kevin Brace <kevinbrace at gmx.com>
Date: Fri Oct 18 09:15:34 2019 -0700
drm/openchrome: Move cursor memory allocation code inside openchrome_crtc.c
Signed-off-by: Kevin Brace <kevinbrace at gmx.com>
diff --git a/drivers/gpu/drm/openchrome/openchrome_crtc.c b/drivers/gpu/drm/openchrome/openchrome_crtc.c
index 726b391917fb..21604c3b99ed 100644
--- a/drivers/gpu/drm/openchrome/openchrome_crtc.c
+++ b/drivers/gpu/drm/openchrome/openchrome_crtc.c
@@ -2303,6 +2303,22 @@ int via_crtc_init(struct drm_device *dev, uint32_t index)
goto cleanup_cursor;
}
+ if (dev->pdev->device == PCI_DEVICE_ID_VIA_CLE266 ||
+ dev->pdev->device == PCI_DEVICE_ID_VIA_KM400)
+ cursor_size = 32 * 32 * 4;
+
+ ret = openchrome_bo_create(dev,
+ &dev_private->bdev,
+ cursor_size,
+ ttm_bo_type_kernel,
+ TTM_PL_FLAG_VRAM,
+ true,
+ &iga->cursor_bo);
+ if (ret) {
+ DRM_ERROR("Failed to create cursor.\n");
+ goto cleanup_cursor;
+ }
+
if (iga->index) {
iga->timings.htotal.count = ARRAY_SIZE(iga2_hor_total);
iga->timings.htotal.regs = iga2_hor_total;
@@ -2462,22 +2478,6 @@ int via_crtc_init(struct drm_device *dev, uint32_t index)
gamma[i + 512] = i << 8 | i;
}
- if (dev->pdev->device == PCI_DEVICE_ID_VIA_CLE266
- || dev->pdev->device == PCI_DEVICE_ID_VIA_KM400)
- cursor_size = 32 * 32 * 4;
-
- ret = openchrome_bo_create(dev,
- &dev_private->bdev,
- cursor_size,
- ttm_bo_type_kernel,
- TTM_PL_FLAG_VRAM,
- true,
- &iga->cursor_bo);
- if (ret) {
- DRM_ERROR("Failed to create cursor.\n");
- goto cleanup_cursor;
- }
-
goto exit;
cleanup_cursor:
drm_plane_cleanup(cursor);
commit 44e52b0e3a128fc726641f862b62b081ad30848e
Author: Kevin Brace <kevinbrace at gmx.com>
Date: Fri Oct 18 09:14:55 2019 -0700
drm/openchrome: Consolidate drm_crtc_funcs struct
This simplifies the code.
Signed-off-by: Kevin Brace <kevinbrace at gmx.com>
diff --git a/drivers/gpu/drm/openchrome/openchrome_crtc.c b/drivers/gpu/drm/openchrome/openchrome_crtc.c
index dbadb67ffb16..726b391917fb 100644
--- a/drivers/gpu/drm/openchrome/openchrome_crtc.c
+++ b/drivers/gpu/drm/openchrome/openchrome_crtc.c
@@ -321,13 +321,7 @@ static void openchrome_crtc_destroy(struct drm_crtc *crtc)
drm_crtc_cleanup(crtc);
}
-static const struct drm_crtc_funcs openchrome_iga1_drm_crtc_funcs = {
- .gamma_set = openchrome_gamma_set,
- .set_config = drm_crtc_helper_set_config,
- .destroy = openchrome_crtc_destroy,
-};
-
-static const struct drm_crtc_funcs openchrome_iga2_drm_crtc_funcs = {
+static const struct drm_crtc_funcs openchrome_drm_crtc_funcs = {
.gamma_set = openchrome_gamma_set,
.set_config = drm_crtc_helper_set_config,
.destroy = openchrome_crtc_destroy,
@@ -2296,19 +2290,14 @@ int via_crtc_init(struct drm_device *dev, uint32_t index)
if (iga->index) {
drm_crtc_helper_add(crtc,
&openchrome_iga2_drm_crtc_helper_funcs);
- ret = drm_crtc_init_with_planes(dev, crtc,
- primary, cursor,
- &openchrome_iga2_drm_crtc_funcs,
- NULL);
} else {
drm_crtc_helper_add(crtc,
&openchrome_iga1_drm_crtc_helper_funcs);
- ret = drm_crtc_init_with_planes(dev, crtc,
- primary, cursor,
- &openchrome_iga1_drm_crtc_funcs,
- NULL);
}
+ ret = drm_crtc_init_with_planes(dev, crtc, primary, cursor,
+ &openchrome_drm_crtc_funcs,
+ NULL);
if (ret) {
DRM_ERROR("Failed to initialize CRTC!\n");
goto cleanup_cursor;
commit 252206688aec851a7a066256e63bc7ce75993e7a
Author: Kevin Brace <kevinbrace at gmx.com>
Date: Fri Oct 18 09:14:39 2019 -0700
drm/openchrome: Rename via_crtc_destroy() to openchrome_crtc_destroy()
Signed-off-by: Kevin Brace <kevinbrace at gmx.com>
diff --git a/drivers/gpu/drm/openchrome/openchrome_crtc.c b/drivers/gpu/drm/openchrome/openchrome_crtc.c
index 80f13fb95cb0..dbadb67ffb16 100644
--- a/drivers/gpu/drm/openchrome/openchrome_crtc.c
+++ b/drivers/gpu/drm/openchrome/openchrome_crtc.c
@@ -309,7 +309,7 @@ static void via_iga2_set_color_depth(
DRM_DEBUG_KMS("Exiting %s.\n", __func__);
}
-static void via_crtc_destroy(struct drm_crtc *crtc)
+static void openchrome_crtc_destroy(struct drm_crtc *crtc)
{
struct via_crtc *iga = container_of(crtc, struct via_crtc, base);
@@ -324,13 +324,13 @@ static void via_crtc_destroy(struct drm_crtc *crtc)
static const struct drm_crtc_funcs openchrome_iga1_drm_crtc_funcs = {
.gamma_set = openchrome_gamma_set,
.set_config = drm_crtc_helper_set_config,
- .destroy = via_crtc_destroy,
+ .destroy = openchrome_crtc_destroy,
};
static const struct drm_crtc_funcs openchrome_iga2_drm_crtc_funcs = {
.gamma_set = openchrome_gamma_set,
.set_config = drm_crtc_helper_set_config,
- .destroy = via_crtc_destroy,
+ .destroy = openchrome_crtc_destroy,
};
static void via_load_vpit_regs(
commit f223e7a982c8157a49164ddc326ec7d3cc6bf684
Author: Kevin Brace <kevinbrace at gmx.com>
Date: Fri Oct 18 09:14:09 2019 -0700
drm/openchrome: Merge gamma settings code into openchrome_gamma_set()
Signed-off-by: Kevin Brace <kevinbrace at gmx.com>
diff --git a/drivers/gpu/drm/openchrome/openchrome_crtc.c b/drivers/gpu/drm/openchrome/openchrome_crtc.c
index 4249cc9910e5..80f13fb95cb0 100644
--- a/drivers/gpu/drm/openchrome/openchrome_crtc.c
+++ b/drivers/gpu/drm/openchrome/openchrome_crtc.c
@@ -62,6 +62,147 @@ static struct vga_regset vpit_table[] = {
{VGA_GFX_I, 0x08, 0xFF, 0xFF }
};
+static int openchrome_gamma_set(struct drm_crtc *crtc,
+ u16 *r, u16 *g, u16 *b,
+ uint32_t size,
+ struct drm_modeset_acquire_ctx *ctx)
+{
+ struct via_crtc *iga = container_of(crtc,
+ struct via_crtc, base);
+ struct openchrome_drm_private *dev_private =
+ crtc->dev->dev_private;
+ int end = (size > 256) ? 256 : size, i;
+ u8 val = 0, sr1a = vga_rseq(VGABASE, 0x1A);
+
+ if (!crtc->enabled || !crtc->primary->fb)
+ return -EINVAL;
+
+ if (iga->index) {
+ if (crtc->primary->fb->format->cpp[0] * 8 == 8) {
+ /* Prepare for initialize IGA1's LUT: */
+ vga_wseq(VGABASE, 0x1A, sr1a & 0xFE);
+ /* Change to Primary Display's LUT */
+ val = vga_rseq(VGABASE, 0x1B);
+ vga_wseq(VGABASE, 0x1B, val);
+ val = vga_rcrt(VGABASE, 0x67);
+ vga_wcrt(VGABASE, 0x67, val);
+
+ /* Fill in IGA1's LUT */
+ for (i = 0; i < end; i++) {
+ /* Bit mask of palette */
+ vga_w(VGABASE, VGA_PEL_MSK, 0xFF);
+ vga_w(VGABASE, VGA_PEL_IW, i);
+ vga_w(VGABASE, VGA_PEL_D, r[i] >> 8);
+ vga_w(VGABASE, VGA_PEL_D, g[i] >> 8);
+ vga_w(VGABASE, VGA_PEL_D, b[i] >> 8);
+ }
+ /* enable LUT */
+ svga_wseq_mask(VGABASE, 0x1B, 0x00, BIT(0));
+ /*
+ * Disable gamma in case it was enabled
+ * previously
+ */
+ svga_wcrt_mask(VGABASE, 0x33, 0x00, BIT(7));
+ /* access Primary Display's LUT */
+ vga_wseq(VGABASE, 0x1A, sr1a & 0xFE);
+ } else {
+ /* Enable Gamma */
+ svga_wcrt_mask(VGABASE, 0x33, BIT(7), BIT(7));
+ svga_wseq_mask(VGABASE, 0x1A, 0x00, BIT(0));
+
+ /* Fill in IGA1's gamma */
+ for (i = 0; i < end; i++) {
+ /* bit mask of palette */
+ vga_w(VGABASE, VGA_PEL_MSK, 0xFF);
+ vga_w(VGABASE, VGA_PEL_IW, i);
+ vga_w(VGABASE, VGA_PEL_D, r[i] >> 8);
+ vga_w(VGABASE, VGA_PEL_D, g[i] >> 8);
+ vga_w(VGABASE, VGA_PEL_D, b[i] >> 8);
+ }
+ vga_wseq(VGABASE, 0x1A, sr1a);
+ }
+ } else {
+ if (crtc->primary->fb->format->cpp[0] * 8 == 8) {
+ /* Change Shadow to Secondary Display's LUT */
+ svga_wseq_mask(VGABASE, 0x1A, BIT(0), BIT(0));
+ /* Enable Secondary Display Engine */
+ svga_wseq_mask(VGABASE, 0x1B, BIT(7), BIT(7));
+ /* Second Display Color Depth, 8bpp */
+ svga_wcrt_mask(VGABASE, 0x67, 0x3F, 0x3F);
+
+ /*
+ * Enable second display channel just in case.
+ */
+ if (!(vga_rcrt(VGABASE, 0x6A) & BIT(7)))
+ enable_second_display_channel(VGABASE);
+
+ /* Fill in IGA2's LUT */
+ for (i = 0; i < end; i++) {
+ /* Bit mask of palette */
+ vga_w(VGABASE, VGA_PEL_MSK, 0xFF);
+ vga_w(VGABASE, VGA_PEL_IW, i);
+ vga_w(VGABASE, VGA_PEL_D, r[i] >> 8);
+ vga_w(VGABASE, VGA_PEL_D, g[i] >> 8);
+ vga_w(VGABASE, VGA_PEL_D, b[i] >> 8);
+ }
+ /*
+ * Disable gamma in case it was enabled
+ * previously
+ */
+ svga_wcrt_mask(VGABASE, 0x6A, 0x00, BIT(1));
+
+ /* access Primary Display's LUT */
+ vga_wseq(VGABASE, 0x1A, sr1a & 0xFE);
+ } else {
+ u8 reg_bits = BIT(1);
+
+ svga_wseq_mask(VGABASE, 0x1A, BIT(0), BIT(0));
+ /* Bit 1 enables gamma */
+ svga_wcrt_mask(VGABASE, 0x6A, BIT(1), BIT(1));
+
+ /* Old platforms LUT are 6 bits in size.
+ * Newer it is 8 bits. */
+ switch (crtc->dev->pdev->device) {
+ case PCI_DEVICE_ID_VIA_CLE266:
+ case PCI_DEVICE_ID_VIA_KM400:
+ case PCI_DEVICE_ID_VIA_K8M800:
+ case PCI_DEVICE_ID_VIA_PM800:
+ break;
+
+ default:
+ reg_bits |= BIT(5);
+ break;
+ }
+ svga_wcrt_mask(VGABASE, 0x6A, reg_bits,
+ reg_bits);
+
+ /*
+ * Before we fill the second LUT, we have to
+ * enable second display channel. If it's
+ * enabled before, we don't need to do that,
+ * or else the secondary display will be dark
+ * for about 1 sec and then be turned on
+ * again.
+ */
+ if (!(vga_rcrt(VGABASE, 0x6A) & BIT(7)))
+ enable_second_display_channel(VGABASE);
+
+ /* Fill in IGA2's gamma */
+ for (i = 0; i < end; i++) {
+ /* bit mask of palette */
+ vga_w(VGABASE, VGA_PEL_MSK, 0xFF);
+ vga_w(VGABASE, VGA_PEL_IW, i);
+ vga_w(VGABASE, VGA_PEL_D, r[i] >> 8);
+ vga_w(VGABASE, VGA_PEL_D, g[i] >> 8);
+ vga_w(VGABASE, VGA_PEL_D, b[i] >> 8);
+ }
+ /* access Primary Display's LUT */
+ vga_wseq(VGABASE, 0x1A, sr1a);
+ }
+ }
+ return 0;
+}
+
static void via_iga_common_init(void __iomem *regs)
{
DRM_DEBUG_KMS("Entered %s.\n", __func__);
@@ -168,149 +309,6 @@ static void via_iga2_set_color_depth(
DRM_DEBUG_KMS("Exiting %s.\n", __func__);
}
-static int via_iga1_gamma_set(struct drm_crtc *crtc,
- u16 *r, u16 *g, u16 *b,
- uint32_t size,
- struct drm_modeset_acquire_ctx *ctx)
-{
- struct openchrome_drm_private *dev_private =
- crtc->dev->dev_private;
- int end = (size > 256) ? 256 : size, i;
- u8 val, sr1a = vga_rseq(VGABASE, 0x1A);
-
- if (!crtc->enabled || !crtc->primary->fb)
- return -EINVAL;
-
- if (crtc->primary->fb->format->cpp[0] * 8 == 8) {
- /* Prepare for initialize IGA1's LUT: */
- vga_wseq(VGABASE, 0x1A, sr1a & 0xFE);
- /* Change to Primary Display's LUT */
- val = vga_rseq(VGABASE, 0x1B);
- vga_wseq(VGABASE, 0x1B, val);
- val = vga_rcrt(VGABASE, 0x67);
- vga_wcrt(VGABASE, 0x67, val);
-
- /* Fill in IGA1's LUT */
- for (i = 0; i < end; i++) {
- /* Bit mask of palette */
- vga_w(VGABASE, VGA_PEL_MSK, 0xFF);
- vga_w(VGABASE, VGA_PEL_IW, i);
- vga_w(VGABASE, VGA_PEL_D, r[i] >> 8);
- vga_w(VGABASE, VGA_PEL_D, g[i] >> 8);
- vga_w(VGABASE, VGA_PEL_D, b[i] >> 8);
- }
- /* enable LUT */
- svga_wseq_mask(VGABASE, 0x1B, 0x00, BIT(0));
- /* Disable gamma in case it was enabled previously */
- svga_wcrt_mask(VGABASE, 0x33, 0x00, BIT(7));
- /* access Primary Display's LUT */
- vga_wseq(VGABASE, 0x1A, sr1a & 0xFE);
- } else {
- /* Enable Gamma */
- svga_wcrt_mask(VGABASE, 0x33, BIT(7), BIT(7));
- svga_wseq_mask(VGABASE, 0x1A, 0x00, BIT(0));
-
- /* Fill in IGA1's gamma */
- for (i = 0; i < end; i++) {
- /* bit mask of palette */
- vga_w(VGABASE, VGA_PEL_MSK, 0xFF);
- vga_w(VGABASE, VGA_PEL_IW, i);
- vga_w(VGABASE, VGA_PEL_D, r[i] >> 8);
- vga_w(VGABASE, VGA_PEL_D, g[i] >> 8);
- vga_w(VGABASE, VGA_PEL_D, b[i] >> 8);
- }
- vga_wseq(VGABASE, 0x1A, sr1a);
- }
-
- return 0;
-}
-
-static int via_iga2_gamma_set(struct drm_crtc *crtc,
- u16 *r, u16 *g, u16 *b,
- uint32_t size,
- struct drm_modeset_acquire_ctx *ctx)
-{
- struct openchrome_drm_private *dev_private =
- crtc->dev->dev_private;
- int end = (size > 256) ? 256 : size, i;
- u8 sr1a = vga_rseq(VGABASE, 0x1A);
-
- if (!crtc->enabled || !crtc->primary->fb)
- return -EINVAL;
-
- if (crtc->primary->fb->format->cpp[0] * 8 == 8) {
- /* Change Shadow to Secondary Display's LUT */
- svga_wseq_mask(VGABASE, 0x1A, BIT(0), BIT(0));
- /* Enable Secondary Display Engine */
- svga_wseq_mask(VGABASE, 0x1B, BIT(7), BIT(7));
- /* Second Display Color Depth, 8bpp */
- svga_wcrt_mask(VGABASE, 0x67, 0x3F, 0x3F);
-
- /* Enable second display channel just in case. */
- if (!(vga_rcrt(VGABASE, 0x6A) & BIT(7)))
- enable_second_display_channel(VGABASE);
-
- /* Fill in IGA2's LUT */
- for (i = 0; i < end; i++) {
- /* Bit mask of palette */
- vga_w(VGABASE, VGA_PEL_MSK, 0xFF);
- vga_w(VGABASE, VGA_PEL_IW, i);
- vga_w(VGABASE, VGA_PEL_D, r[i] >> 8);
- vga_w(VGABASE, VGA_PEL_D, g[i] >> 8);
- vga_w(VGABASE, VGA_PEL_D, b[i] >> 8);
- }
- /* Disable gamma in case it was enabled previously */
- svga_wcrt_mask(VGABASE, 0x6A, 0x00, BIT(1));
-
- /* access Primary Display's LUT */
- vga_wseq(VGABASE, 0x1A, sr1a & 0xFE);
- } else {
- u8 reg_bits = BIT(1);
-
- svga_wseq_mask(VGABASE, 0x1A, BIT(0), BIT(0));
- /* Bit 1 enables gamma */
- svga_wcrt_mask(VGABASE, 0x6A, BIT(1), BIT(1));
-
- /* Old platforms LUT are 6 bits in size.
- * Newer it is 8 bits. */
- switch (crtc->dev->pdev->device) {
- case PCI_DEVICE_ID_VIA_CLE266:
- case PCI_DEVICE_ID_VIA_KM400:
- case PCI_DEVICE_ID_VIA_K8M800:
- case PCI_DEVICE_ID_VIA_PM800:
- break;
-
- default:
- reg_bits |= BIT(5);
- break;
- }
- svga_wcrt_mask(VGABASE, 0x6A, reg_bits, reg_bits);
-
- /* Before we fill the second LUT, we have to enable
- * second display channel. If it's enabled before,
- * we don't need to do that, or else the secondary
- * display will be dark for about 1 sec and then be
- * turned on again.
- */
- if (!(vga_rcrt(VGABASE, 0x6A) & BIT(7)))
- enable_second_display_channel(VGABASE);
-
- /* Fill in IGA2's gamma */
- for (i = 0; i < end; i++) {
- /* bit mask of palette */
- vga_w(VGABASE, VGA_PEL_MSK, 0xFF);
- vga_w(VGABASE, VGA_PEL_IW, i);
- vga_w(VGABASE, VGA_PEL_D, r[i] >> 8);
- vga_w(VGABASE, VGA_PEL_D, g[i] >> 8);
- vga_w(VGABASE, VGA_PEL_D, b[i] >> 8);
- }
- /* access Primary Display's LUT */
- vga_wseq(VGABASE, 0x1A, sr1a);
- }
-
- return 0;
-}
-
static void via_crtc_destroy(struct drm_crtc *crtc)
{
struct via_crtc *iga = container_of(crtc, struct via_crtc, base);
@@ -324,13 +322,13 @@ static void via_crtc_destroy(struct drm_crtc *crtc)
}
static const struct drm_crtc_funcs openchrome_iga1_drm_crtc_funcs = {
- .gamma_set = via_iga1_gamma_set,
+ .gamma_set = openchrome_gamma_set,
.set_config = drm_crtc_helper_set_config,
.destroy = via_crtc_destroy,
};
static const struct drm_crtc_funcs openchrome_iga2_drm_crtc_funcs = {
- .gamma_set = via_iga2_gamma_set,
+ .gamma_set = openchrome_gamma_set,
.set_config = drm_crtc_helper_set_config,
.destroy = via_crtc_destroy,
};
commit ed30a7402741939cb07dc640cbc736aeb4be8599
Author: Kevin Brace <kevinbrace at gmx.com>
Date: Fri Oct 18 09:13:36 2019 -0700
drm/openchrome: Discontinue openchrome_display.h
The code was moved into openchrome_drv.h.
Signed-off-by: Kevin Brace <kevinbrace at gmx.com>
diff --git a/drivers/gpu/drm/openchrome/openchrome_display.h b/drivers/gpu/drm/openchrome/openchrome_display.h
deleted file mode 100644
index faff26f2b30d..000000000000
--- a/drivers/gpu/drm/openchrome/openchrome_display.h
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright 2012 James Simmons <jsimmons at infradead.org> All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sub license,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) OR COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-#ifndef _VIA_DISPLAY_H_
-#define _VIA_DISPLAY_H_
-
-#include <linux/pci.h>
-#include <linux/pci_ids.h>
-
-#include <video/vga.h>
-
-#include <drm/drm_crtc.h>
-#include <drm/drm_crtc_helper.h>
-#include <drm/drm_edid.h>
-#include <drm/drm_fb_helper.h>
-#include <drm/drm_plane_helper.h>
-
-#include "openchrome_crtc_hw.h"
-
-
-/* IGA Scaling disable */
-#define VIA_NO_SCALING 0
-
-/* IGA Scaling down */
-#define VIA_HOR_SHRINK BIT(0)
-#define VIA_VER_SHRINK BIT(1)
-#define VIA_SHRINK (BIT(0) | BIT(1))
-
-/* IGA Scaling up */
-#define VIA_HOR_EXPAND BIT(2)
-#define VIA_VER_EXPAND BIT(3)
-#define VIA_EXPAND (BIT(2) | BIT(3))
-
-/* Define IGA Scaling up/down status : Horizontal or Vertical */
-/* Is IGA Hor scaling up/down status */
-#define HOR_SCALE BIT(0)
-/* Is IGA Ver scaling up/down status */
-#define VER_SCALE BIT(1)
-/* Is IGA Hor and Ver scaling up/down status */
-#define HOR_VER_SCALE (BIT(0) | BIT(1))
-
-#define VIA_I2C_NONE 0x0
-#define VIA_I2C_BUS1 BIT(0)
-#define VIA_I2C_BUS2 BIT(1)
-#define VIA_I2C_BUS3 BIT(2)
-#define VIA_I2C_BUS4 BIT(3)
-#define VIA_I2C_BUS5 BIT(4)
-
-#define VIA_DI_PORT_NONE 0x0
-#define VIA_DI_PORT_DIP0 BIT(0)
-#define VIA_DI_PORT_DIP1 BIT(1)
-#define VIA_DI_PORT_DVP0 BIT(2)
-#define VIA_DI_PORT_DVP1 BIT(3)
-#define VIA_DI_PORT_DFPL BIT(4)
-#define VIA_DI_PORT_FPDPLOW BIT(4)
-#define VIA_DI_PORT_DFPH BIT(5)
-#define VIA_DI_PORT_FPDPHIGH BIT(5)
-#define VIA_DI_PORT_DFP BIT(6)
-#define VIA_DI_PORT_LVDS1 BIT(7)
-#define VIA_DI_PORT_TMDS BIT(7)
-#define VIA_DI_PORT_LVDS2 BIT(8)
-
-/* External TMDS (DVI) Transmitter Type */
-#define VIA_TMDS_NONE 0x0
-#define VIA_TMDS_VT1632 BIT(0)
-#define VIA_TMDS_SII164 BIT(1)
-
-
-typedef struct _via_fp_info {
- u32 x;
- u32 y;
-} via_fp_info;
-
-struct via_crtc {
- struct drm_crtc base;
- struct openchrome_bo *cursor_bo;
- struct crtc_timings pixel_timings;
- struct crtc_timings timings;
- struct vga_registers display_queue;
- struct vga_registers high_threshold;
- struct vga_registers threshold;
- struct vga_registers fifo_depth;
- struct vga_registers offset;
- struct vga_registers fetch;
- int scaling_mode;
- uint8_t index;
-};
-
-struct via_connector {
- struct drm_connector base;
- u32 i2c_bus;
- struct list_head props;
- uint32_t flags;
-};
-
-struct via_encoder {
- struct drm_encoder base;
- u32 i2c_bus;
- u32 di_port;
- struct via_connector cons[];
-};
-
-static inline void
-via_lock_crtc(void __iomem *regs)
-{
- svga_wcrt_mask(regs, 0x11, BIT(7), BIT(7));
-}
-
-static inline void
-via_unlock_crtc(void __iomem *regs, int pci_id)
-{
- u8 mask = BIT(0);
-
- svga_wcrt_mask(regs, 0x11, 0, BIT(7));
- if ((pci_id == PCI_DEVICE_ID_VIA_VX875) ||
- (pci_id == PCI_DEVICE_ID_VIA_VX900_VGA))
- mask = BIT(4);
- svga_wcrt_mask(regs, 0x47, 0, mask);
-}
-
-static inline void
-enable_second_display_channel(void __iomem *regs)
-{
- svga_wcrt_mask(regs, 0x6A, BIT(7), BIT(7));
-}
-
-static inline void
-disable_second_display_channel(void __iomem *regs)
-{
- svga_wcrt_mask(regs, 0x6A, 0x00, BIT(7));
-}
-
-/* display */
-extern int via_modeset_init(struct drm_device *dev);
-extern void via_modeset_fini(struct drm_device *dev);
-
-/* i2c */
-extern struct i2c_adapter *via_find_ddc_bus(int port);
-extern void via_i2c_readbytes(struct i2c_adapter *adapter,
- u8 slave_addr, char offset,
- u8 *buffer, unsigned int size);
-extern void via_i2c_writebytes(struct i2c_adapter *adapter,
- u8 slave_addr, char offset,
- u8 *data, unsigned int size);
-extern int via_i2c_init(struct drm_device *dev);
-extern void via_i2c_exit(void);
-
-/* clock */
-extern u32 via_get_clk_value(struct drm_device *dev, u32 clk);
-extern void via_set_vclock(struct drm_crtc *crtc, u32 clk);
-
-/* framebuffers */
-extern int via_fbdev_init(struct drm_device *dev);
-extern void via_fbdev_fini(struct drm_device *dev);
-
-/* crtc */
-extern void via_load_crtc_pixel_timing(struct drm_crtc *crtc,
- struct drm_display_mode *mode);
-extern int via_crtc_init(struct drm_device *dev, uint32_t index);
-
-/* encoders */
-extern void via_set_sync_polarity(struct drm_encoder *encoder,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode);
-extern struct drm_encoder *via_best_encoder(struct drm_connector *connector);
-extern void via_encoder_cleanup(struct drm_encoder *encoder);
-extern void via_encoder_prepare(struct drm_encoder *encoder);
-extern void via_encoder_disable(struct drm_encoder *encoder);
-extern void via_encoder_commit(struct drm_encoder *encoder);
-
-/* connectors */
-extern int via_connector_set_property(struct drm_connector *connector,
- struct drm_property *property,
- uint64_t value);
-extern int via_connector_mode_valid(struct drm_connector *connector,
- struct drm_display_mode *mode);
-extern void via_connector_destroy(struct drm_connector *connector);
-
-extern void via_analog_probe(struct drm_device *dev);
-extern bool openchrome_vt1632_probe(struct i2c_adapter *i2c_bus);
-extern bool openchrome_sii164_probe(struct i2c_adapter *i2c_bus);
-extern void openchrome_ext_dvi_probe(struct drm_device *dev);
-extern void via_tmds_probe(struct drm_device *dev);
-extern void via_fp_probe(struct drm_device *dev);
-
-extern void via_hdmi_init(struct drm_device *dev, u32 di_port);
-extern void via_analog_init(struct drm_device *dev);
-extern void openchrome_vt1632_init(struct drm_device *dev);
-extern void openchrome_sii164_init(struct drm_device *dev);
-extern void openchrome_ext_dvi_init(struct drm_device *dev);
-extern void via_tmds_init(struct drm_device *dev);
-extern void via_fp_init(struct drm_device *dev);
-
-#endif
diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.h b/drivers/gpu/drm/openchrome/openchrome_drv.h
index c34d78f5a2b9..448e2570c3f2 100644
--- a/drivers/gpu/drm/openchrome/openchrome_drv.h
+++ b/drivers/gpu/drm/openchrome/openchrome_drv.h
@@ -1,5 +1,6 @@
/*
* Copyright © 2019 Kevin Brace
+ * Copyright 2012 James Simmons <jsimmons at infradead.org>. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -26,6 +27,7 @@
* Author(s):
*
* Kevin Brace <kevinbrace at gmx.com>
+ * James Simmons <jsimmons at infradead.org>
*/
#ifndef _OPENCHROME_DRV_H
@@ -33,9 +35,16 @@
#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/pci_ids.h>
#include <video/vga.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_encoder.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_framebuffer.h>
#include <drm/drm_gem.h>
#include <drm/drm_ioctl.h>
#include <drm/drm_plane.h>
@@ -46,7 +55,7 @@
#include <drm/via_drm.h>
-#include "openchrome_display.h"
+#include "openchrome_crtc_hw.h"
#include "openchrome_regs.h"
@@ -93,6 +102,87 @@
#define VIA_MEM_DDR3_1333 0x11
#define VIA_MEM_DDR3_1600 0x12
+/* IGA Scaling disable */
+#define VIA_NO_SCALING 0
+
+/* IGA Scaling down */
+#define VIA_HOR_SHRINK BIT(0)
+#define VIA_VER_SHRINK BIT(1)
+#define VIA_SHRINK (BIT(0) | BIT(1))
+
+/* IGA Scaling up */
+#define VIA_HOR_EXPAND BIT(2)
+#define VIA_VER_EXPAND BIT(3)
+#define VIA_EXPAND (BIT(2) | BIT(3))
+
+/* Define IGA Scaling up/down status : Horizontal or Vertical */
+/* Is IGA Hor scaling up/down status */
+#define HOR_SCALE BIT(0)
+/* Is IGA Ver scaling up/down status */
+#define VER_SCALE BIT(1)
+/* Is IGA Hor and Ver scaling up/down status */
+#define HOR_VER_SCALE (BIT(0) | BIT(1))
+
+#define VIA_I2C_NONE 0x0
+#define VIA_I2C_BUS1 BIT(0)
+#define VIA_I2C_BUS2 BIT(1)
+#define VIA_I2C_BUS3 BIT(2)
+#define VIA_I2C_BUS4 BIT(3)
+#define VIA_I2C_BUS5 BIT(4)
+
+#define VIA_DI_PORT_NONE 0x0
+#define VIA_DI_PORT_DIP0 BIT(0)
+#define VIA_DI_PORT_DIP1 BIT(1)
+#define VIA_DI_PORT_DVP0 BIT(2)
+#define VIA_DI_PORT_DVP1 BIT(3)
+#define VIA_DI_PORT_DFPL BIT(4)
+#define VIA_DI_PORT_FPDPLOW BIT(4)
+#define VIA_DI_PORT_DFPH BIT(5)
+#define VIA_DI_PORT_FPDPHIGH BIT(5)
+#define VIA_DI_PORT_DFP BIT(6)
+#define VIA_DI_PORT_LVDS1 BIT(7)
+#define VIA_DI_PORT_TMDS BIT(7)
+#define VIA_DI_PORT_LVDS2 BIT(8)
+
+/* External TMDS (DVI) Transmitter Type */
+#define VIA_TMDS_NONE 0x0
+#define VIA_TMDS_VT1632 BIT(0)
+#define VIA_TMDS_SII164 BIT(1)
+
+
+typedef struct _via_fp_info {
+ u32 x;
+ u32 y;
+} via_fp_info;
+
+struct via_crtc {
+ struct drm_crtc base;
+ struct openchrome_bo *cursor_bo;
+ struct crtc_timings pixel_timings;
+ struct crtc_timings timings;
+ struct vga_registers display_queue;
+ struct vga_registers high_threshold;
+ struct vga_registers threshold;
+ struct vga_registers fifo_depth;
+ struct vga_registers offset;
+ struct vga_registers fetch;
+ int scaling_mode;
+ uint8_t index;
+};
+
+struct via_connector {
+ struct drm_connector base;
+ u32 i2c_bus;
+ struct list_head props;
+ uint32_t flags;
+};
+
+struct via_encoder {
+ struct drm_encoder base;
+ u32 i2c_bus;
+ u32 di_port;
+ struct via_connector cons[];
+};
struct via_state {
struct vga_regset crt_regs[256];
@@ -255,6 +345,38 @@ struct openchrome_drm_private {
#define VGABASE (VIA_BASE+VIA_MMIO_VGABASE)
+
+static inline void
+via_lock_crtc(void __iomem *regs)
+{
+ svga_wcrt_mask(regs, 0x11, BIT(7), BIT(7));
+}
+
+static inline void
+via_unlock_crtc(void __iomem *regs, int pci_id)
+{
+ u8 mask = BIT(0);
+
+ svga_wcrt_mask(regs, 0x11, 0, BIT(7));
+ if ((pci_id == PCI_DEVICE_ID_VIA_VX875) ||
+ (pci_id == PCI_DEVICE_ID_VIA_VX900_VGA))
+ mask = BIT(4);
+ svga_wcrt_mask(regs, 0x47, 0, mask);
+}
+
+static inline void
+enable_second_display_channel(void __iomem *regs)
+{
+ svga_wcrt_mask(regs, 0x6A, BIT(7), BIT(7));
+}
+
+static inline void
+disable_second_display_channel(void __iomem *regs)
+{
+ svga_wcrt_mask(regs, 0x6A, 0x00, BIT(7));
+}
+
+
extern const struct drm_ioctl_desc via_ioctls[];
extern int via_max_ioctl;
@@ -318,4 +440,65 @@ extern const unsigned int openchrome_cursor_formats_size;
extern struct drm_fb_helper_funcs via_drm_fb_helper_funcs;
+/* display */
+extern int via_modeset_init(struct drm_device *dev);
+extern void via_modeset_fini(struct drm_device *dev);
+
+/* i2c */
+extern struct i2c_adapter *via_find_ddc_bus(int port);
+extern void via_i2c_readbytes(struct i2c_adapter *adapter,
+ u8 slave_addr, char offset,
+ u8 *buffer, unsigned int size);
+extern void via_i2c_writebytes(struct i2c_adapter *adapter,
+ u8 slave_addr, char offset,
+ u8 *data, unsigned int size);
+extern int via_i2c_init(struct drm_device *dev);
+extern void via_i2c_exit(void);
+
+/* clock */
+extern u32 via_get_clk_value(struct drm_device *dev, u32 clk);
+extern void via_set_vclock(struct drm_crtc *crtc, u32 clk);
+
+/* framebuffers */
+extern int via_fbdev_init(struct drm_device *dev);
+extern void via_fbdev_fini(struct drm_device *dev);
+
+/* crtc */
+extern void via_load_crtc_pixel_timing(struct drm_crtc *crtc,
+ struct drm_display_mode *mode);
+extern int via_crtc_init(struct drm_device *dev, uint32_t index);
+
+/* encoders */
+extern void via_set_sync_polarity(struct drm_encoder *encoder,
+ struct drm_display_mode *mode,
+ struct drm_display_mode *adjusted_mode);
+extern struct drm_encoder *via_best_encoder(struct drm_connector *connector);
+extern void via_encoder_cleanup(struct drm_encoder *encoder);
+extern void via_encoder_prepare(struct drm_encoder *encoder);
+extern void via_encoder_disable(struct drm_encoder *encoder);
+extern void via_encoder_commit(struct drm_encoder *encoder);
+
+/* connectors */
+extern int via_connector_set_property(struct drm_connector *connector,
+ struct drm_property *property,
+ uint64_t value);
+extern int via_connector_mode_valid(struct drm_connector *connector,
+ struct drm_display_mode *mode);
+extern void via_connector_destroy(struct drm_connector *connector);
+
+extern void via_analog_probe(struct drm_device *dev);
+extern bool openchrome_vt1632_probe(struct i2c_adapter *i2c_bus);
+extern bool openchrome_sii164_probe(struct i2c_adapter *i2c_bus);
+extern void openchrome_ext_dvi_probe(struct drm_device *dev);
+extern void via_tmds_probe(struct drm_device *dev);
+extern void via_fp_probe(struct drm_device *dev);
+
+extern void via_hdmi_init(struct drm_device *dev, u32 di_port);
+extern void via_analog_init(struct drm_device *dev);
+extern void openchrome_vt1632_init(struct drm_device *dev);
+extern void openchrome_sii164_init(struct drm_device *dev);
+extern void openchrome_ext_dvi_init(struct drm_device *dev);
+extern void via_tmds_init(struct drm_device *dev);
+extern void via_fp_init(struct drm_device *dev);
+
#endif /* _OPENCHROME_DRV_H */
More information about the openchrome-devel
mailing list