[openchrome-devel] drm-openchrome: Branch 'drm-next-5.10' - 3 commits - drivers/gpu/drm
Kevin Brace
kevinbrace at kemper.freedesktop.org
Tue Sep 15 01:18:46 UTC 2020
drivers/gpu/drm/openchrome/openchrome_crtc.c | 64 ++++++++----
drivers/gpu/drm/openchrome/openchrome_display.c | 26 ++++
drivers/gpu/drm/openchrome/openchrome_drv.c | 128 ++++++++----------------
drivers/gpu/drm/openchrome/openchrome_drv.h | 11 +-
drivers/gpu/drm/openchrome/openchrome_init.c | 68 ++++++++++++
5 files changed, 189 insertions(+), 108 deletions(-)
New commits:
commit 808eafb07ed3e7a5115982621435b463272d5c90
Author: Kevin Brace <kevinbrace at gmx.com>
Date: Mon Sep 14 18:17:09 2020 -0700
drm/openchrome: Version bumped to 3.3.7
Signed-off-by: Kevin Brace <kevinbrace at gmx.com>
diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.h b/drivers/gpu/drm/openchrome/openchrome_drv.h
index 09d97e97027e..1969f541d860 100644
--- a/drivers/gpu/drm/openchrome/openchrome_drv.h
+++ b/drivers/gpu/drm/openchrome/openchrome_drv.h
@@ -61,7 +61,7 @@
#define DRIVER_MAJOR 3
#define DRIVER_MINOR 3
-#define DRIVER_PATCHLEVEL 6
+#define DRIVER_PATCHLEVEL 7
#define DRIVER_NAME "openchrome"
#define DRIVER_DESC "OpenChrome DRM for VIA Technologies Chrome IGP"
#define DRIVER_DATE "20200914"
commit f6890fe77c160a23c19797b75011ef126e72bfc4
Author: Kevin Brace <kevinbrace at gmx.com>
Date: Mon Sep 14 17:33:11 2020 -0700
drm/openchrome: Migrate to using probe() callback for initialization
This discontinues the use of load() / unload() callbacks of drm_driver
struct. This is a long overdue change to the code.
Signed-off-by: Kevin Brace <kevinbrace at gmx.com>
diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.c b/drivers/gpu/drm/openchrome/openchrome_drv.c
index a415d629d915..7a106b50f572 100644
--- a/drivers/gpu/drm/openchrome/openchrome_drv.c
+++ b/drivers/gpu/drm/openchrome/openchrome_drv.c
@@ -46,6 +46,33 @@ static struct pci_device_id via_pci_table[] = {
};
MODULE_DEVICE_TABLE(pci, via_pci_table);
+static int openchrome_drm_driver_open(struct drm_device *dev,
+ struct drm_file *file_priv)
+{
+ int ret = 0;
+
+ DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
+ DRM_DEBUG_KMS("Exiting %s.\n", __func__);
+ return ret;
+}
+
+static void openchrome_drm_driver_postclose(struct drm_device *dev,
+ struct drm_file *file_priv)
+{
+ DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
+ DRM_DEBUG_KMS("Exiting %s.\n", __func__);
+}
+
+static void openchrome_drm_driver_lastclose(struct drm_device *dev)
+{
+ DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
+ drm_fb_helper_lastclose(dev);
+
+ DRM_DEBUG_KMS("Exiting %s.\n", __func__);
+}
static int openchrome_drm_driver_dumb_create(
struct drm_file *file_priv,
@@ -118,82 +145,6 @@ exit:
return ret;
}
-static void openchrome_driver_unload(struct drm_device *dev)
-{
- struct openchrome_drm_private *dev_private = dev->dev_private;
-
- DRM_DEBUG_KMS("Entered %s.\n", __func__);
-
- via_modeset_fini(dev);
-
- openchrome_mm_fini(dev_private);
- openchrome_device_fini(dev_private);
-
- kfree(dev_private);
-
- DRM_DEBUG_KMS("Exiting %s.\n", __func__);
- return;
-}
-
-static int openchrome_driver_load(struct drm_device *dev,
- unsigned long chipset)
-{
- struct openchrome_drm_private *dev_private;
- int ret = 0;
-
- DRM_DEBUG_KMS("Entered %s.\n", __func__);
-
- dev_private = kzalloc(sizeof(struct openchrome_drm_private),
- GFP_KERNEL);
- if (!dev_private) {
- ret = -ENOMEM;
- DRM_ERROR("Failed to allocate private "
- "storage memory.\n");
- goto exit;
- }
-
- dev->dev_private = (void *) dev_private;
- dev_private->vram_mtrr = -ENXIO;
- dev_private->dev = dev;
-
- ret = openchrome_device_init(dev_private);
- if (ret) {
- DRM_ERROR("Failed to initialize Chrome IGP.\n");
- goto init_error;
- }
-
- ret = openchrome_mm_init(dev_private);
- if (ret) {
- DRM_ERROR("Failed to initialize TTM.\n");
- goto init_error;
- }
-
- chip_revision_info(dev_private);
-
- ret = via_modeset_init(dev);
- if (ret) {
- DRM_ERROR("Failed to initialize mode setting.\n");
- goto init_error;
- }
-
- goto exit;
-init_error:
- if (ret)
- openchrome_driver_unload(dev);
-exit:
- DRM_DEBUG_KMS("Exiting %s.\n", __func__);
- return ret;
-}
-
-static void openchrome_driver_lastclose(struct drm_device *dev)
-{
- DRM_DEBUG_KMS("Entered %s.\n", __func__);
-
- dev->mode_config.funcs->output_poll_changed(dev);
-
- DRM_DEBUG_KMS("Exiting %s.\n", __func__);
-}
-
static int openchrome_drm_mmap(struct file *filp, struct vm_area_struct *vma)
{
struct drm_file *file_priv = filp->private_data;
@@ -230,13 +181,13 @@ static const struct file_operations via_driver_fops = {
.llseek = noop_llseek,
};
-static struct drm_driver via_driver = {
+static struct drm_driver openchrome_driver = {
.driver_features = DRIVER_HAVE_IRQ |
DRIVER_GEM |
DRIVER_MODESET,
- .load = openchrome_driver_load,
- .unload = openchrome_driver_unload,
- .lastclose = openchrome_driver_lastclose,
+ .open = openchrome_drm_driver_open,
+ .postclose = openchrome_drm_driver_postclose,
+ .lastclose = openchrome_drm_driver_lastclose,
.dumb_create = openchrome_drm_driver_dumb_create,
.dumb_map_offset =
openchrome_drm_driver_dumb_map_offset,
@@ -258,20 +209,28 @@ static int openchrome_pci_probe(struct pci_dev *pdev,
DRM_DEBUG_KMS("Entered %s.\n", __func__);
+ ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev,
+ "openchromedrmfb");
+ if (ret) {
+ goto exit;
+ }
+
ret = pci_enable_device(pdev);
if (ret) {
goto exit;
}
- dev = drm_dev_alloc(&via_driver, &pdev->dev);
+ dev = drm_dev_alloc(&openchrome_driver, &pdev->dev);
if (IS_ERR(dev)) {
ret = PTR_ERR(dev);
- goto err_pci_disable_device;
+ goto error_disable_pci;
}
dev->pdev = pdev;
pci_set_drvdata(pdev, dev);
+ ret = openchrome_drm_init(dev);
+
ret = drm_dev_register(dev, ent->driver_data);
if (ret) {
goto err_drm_dev_put;
@@ -280,7 +239,7 @@ static int openchrome_pci_probe(struct pci_dev *pdev,
goto exit;
err_drm_dev_put:
drm_dev_put(dev);
-err_pci_disable_device:
+error_disable_pci:
pci_disable_device(pdev);
exit:
DRM_DEBUG_KMS("Exiting %s.\n", __func__);
@@ -293,6 +252,7 @@ static void openchrome_pci_remove(struct pci_dev *pdev)
DRM_DEBUG_KMS("Entered %s.\n", __func__);
+ openchrome_drm_fini(dev);
drm_dev_unregister(dev);
drm_dev_put(dev);
@@ -313,7 +273,7 @@ static int __init openchrome_init(void)
DRM_DEBUG_KMS("Entered %s.\n", __func__);
- via_driver.num_ioctls = openchrome_max_ioctl;
+ openchrome_driver.num_ioctls = openchrome_max_ioctl;
ret = pci_register_driver(&via_pci_driver);
diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.h b/drivers/gpu/drm/openchrome/openchrome_drv.h
index 31e5d040ed10..09d97e97027e 100644
--- a/drivers/gpu/drm/openchrome/openchrome_drv.h
+++ b/drivers/gpu/drm/openchrome/openchrome_drv.h
@@ -386,6 +386,8 @@ void openchrome_graphics_unlock(
void chip_revision_info(struct openchrome_drm_private *dev_private);
int openchrome_device_init(struct openchrome_drm_private *dev_private);
void openchrome_device_fini(struct openchrome_drm_private *dev_private);
+int openchrome_drm_init(struct drm_device *dev);
+void openchrome_drm_fini(struct drm_device *dev);
int openchrome_dev_pm_ops_suspend(struct device *dev);
int openchrome_dev_pm_ops_resume(struct device *dev);
diff --git a/drivers/gpu/drm/openchrome/openchrome_init.c b/drivers/gpu/drm/openchrome/openchrome_init.c
index e0432595eda1..5b1a8ae23f80 100644
--- a/drivers/gpu/drm/openchrome/openchrome_init.c
+++ b/drivers/gpu/drm/openchrome/openchrome_init.c
@@ -1241,3 +1241,71 @@ void openchrome_device_fini(struct openchrome_drm_private *dev_private)
DRM_DEBUG_KMS("Exiting %s.\n", __func__);
}
+
+int openchrome_drm_init(struct drm_device *dev)
+{
+ struct openchrome_drm_private *dev_private;
+ int ret = 0;
+
+ DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
+ dev_private = kzalloc(sizeof(struct openchrome_drm_private),
+ GFP_KERNEL);
+ if (!dev_private) {
+ ret = -ENOMEM;
+ DRM_ERROR("Failed to allocate private "
+ "storage memory.\n");
+ goto exit;
+ }
+
+ dev->dev_private = (void *) dev_private;
+ dev_private->dev = dev;
+ dev_private->vram_mtrr = -ENXIO;
+
+ ret = openchrome_device_init(dev_private);
+ if (ret) {
+ DRM_ERROR("Failed to initialize Chrome IGP.\n");
+ goto error_free_private;
+ }
+
+ ret = openchrome_mm_init(dev_private);
+ if (ret) {
+ DRM_ERROR("Failed to initialize TTM.\n");
+ goto error_free_private;
+ }
+
+ chip_revision_info(dev_private);
+
+ ret = via_modeset_init(dev);
+ if (ret) {
+ DRM_ERROR("Failed to initialize mode setting.\n");
+ goto error_modeset;
+ }
+
+ goto exit;
+error_modeset:
+ via_modeset_fini(dev);
+ openchrome_mm_fini(dev_private);
+ openchrome_mmio_fini(dev_private);
+ openchrome_vram_fini(dev_private);
+error_free_private:
+ kfree(dev_private);
+exit:
+ DRM_DEBUG_KMS("Exiting %s.\n", __func__);
+ return ret;
+}
+
+void openchrome_drm_fini(struct drm_device *dev)
+{
+ struct openchrome_drm_private *dev_private = dev->dev_private;
+
+ DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
+ via_modeset_fini(dev);
+ openchrome_mm_fini(dev_private);
+ openchrome_mmio_fini(dev_private);
+ openchrome_vram_fini(dev_private);
+ kfree(dev_private);
+
+ DRM_DEBUG_KMS("Exiting %s.\n", __func__);
+}
commit e3a26f777b06e0d8a02868cbd2916484b51da940
Author: Kevin Brace <kevinbrace at gmx.com>
Date: Mon Sep 14 16:54:50 2020 -0700
drm/openchrome: Initialize plane and crtc separately
Also, improve the error condition handling.
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 b35fa2d1fd22..e42b98f906fe 100644
--- a/drivers/gpu/drm/openchrome/openchrome_crtc.c
+++ b/drivers/gpu/drm/openchrome/openchrome_crtc.c
@@ -2239,17 +2239,23 @@ static const uint32_t openchrome_primary_formats[] = {
DRM_FORMAT_RGB332,
};
-int openchrome_crtc_init(struct openchrome_drm_private *dev_private,
- uint32_t index)
+int openchrome_plane_init(struct openchrome_drm_private *dev_private,
+ struct drm_plane **p_primary,
+ struct drm_plane **p_cursor)
{
struct drm_device *dev = dev_private->dev;
- struct via_crtc *iga;
- struct drm_plane *primary;
- struct drm_plane *cursor;
+ struct drm_plane *primary = NULL;
+ struct drm_plane *cursor = NULL;
uint32_t possible_crtcs;
+ uint32_t i;
int ret;
- possible_crtcs = 1 << index;
+ DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
+ possible_crtcs = 0;
+ for (i = 0; i < OPENCHROME_MAX_CRTC; i++) {
+ possible_crtcs |= 1 << i;
+ }
primary = kzalloc(sizeof(struct drm_plane), GFP_KERNEL);
if (!primary) {
@@ -2287,15 +2293,43 @@ int openchrome_crtc_init(struct openchrome_drm_private *dev_private,
goto free_cursor;
}
+ goto exit;
+free_cursor:
+ kfree(cursor);
+ cursor = NULL;
+cleanup_primary:
+ drm_plane_cleanup(primary);
+free_primary:
+ kfree(primary);
+ primary = NULL;
+exit:
+ *p_primary = primary;
+ *p_cursor = cursor;
+
+ DRM_DEBUG_KMS("Exiting %s.\n", __func__);
+ return ret;
+}
+
+int openchrome_crtc_init(struct openchrome_drm_private *dev_private,
+ struct drm_plane *primary,
+ struct drm_plane *cursor,
+ uint32_t i)
+{
+ struct drm_device *dev = dev_private->dev;
+ struct via_crtc *iga;
+ int ret;
+
+ DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
iga = kzalloc(sizeof(struct via_crtc), GFP_KERNEL);
if (!iga) {
ret = -ENOMEM;
DRM_ERROR("Failed to allocate CRTC storage.\n");
- goto cleanup_cursor;
+ goto exit;
}
drm_crtc_helper_add(&iga->base,
- &openchrome_drm_crtc_helper_funcs);
+ &openchrome_drm_crtc_helper_funcs);
ret = drm_crtc_init_with_planes(dev, &iga->base,
primary, cursor,
&openchrome_drm_crtc_funcs,
@@ -2305,20 +2339,12 @@ int openchrome_crtc_init(struct openchrome_drm_private *dev_private,
goto free_crtc;
}
- iga->index = index;
-
- openchrome_crtc_param_init(dev_private, &iga->base, index);
+ iga->index = i;
+ openchrome_crtc_param_init(dev_private, &iga->base, i);
goto exit;
free_crtc:
kfree(iga);
-cleanup_cursor:
- drm_plane_cleanup(cursor);
-free_cursor:
- kfree(cursor);
-cleanup_primary:
- drm_plane_cleanup(primary);
-free_primary:
- kfree(primary);
exit:
+ DRM_DEBUG_KMS("Exiting %s.\n", __func__);
return ret;
}
diff --git a/drivers/gpu/drm/openchrome/openchrome_display.c b/drivers/gpu/drm/openchrome/openchrome_display.c
index 63cee530bc45..9b91fd091282 100644
--- a/drivers/gpu/drm/openchrome/openchrome_display.c
+++ b/drivers/gpu/drm/openchrome/openchrome_display.c
@@ -460,9 +460,13 @@ int
via_modeset_init(struct drm_device *dev)
{
struct openchrome_drm_private *dev_private = dev->dev_private;
+ struct drm_plane *primary;
+ struct drm_plane *cursor;
uint32_t i;
int ret = 0;
+ DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
openchrome_mode_config_init(dev_private);
/* Initialize the number of display connectors. */
@@ -474,10 +478,20 @@ via_modeset_init(struct drm_device *dev)
via_i2c_init(dev);
via_hwcursor_init(dev_private);
+ ret = openchrome_plane_init(dev_private, &primary, &cursor);
+ if (ret) {
+ DRM_ERROR("Failed to initialize planes!\n");
+ goto free_i2c;
+ }
+
for (i = 0; i < OPENCHROME_MAX_CRTC; i++) {
- ret = openchrome_crtc_init(dev_private, i);
+ ret = openchrome_crtc_init(dev_private,
+ primary,
+ cursor,
+ i);
if (ret) {
- goto exit;
+ DRM_ERROR("Failed to initialize CRTC!\n");
+ goto free_crtc;
}
}
@@ -507,11 +521,17 @@ via_modeset_init(struct drm_device *dev)
/* Initialize the frame buffer device. */
ret = via_fbdev_init(dev);
if (ret) {
- goto exit;
+ goto free_crtc;
}
drm_kms_helper_poll_init(dev);
+ goto exit;
+free_crtc:
+ drm_mode_config_cleanup(dev);
+free_i2c:
+ via_i2c_exit();
exit:
+ DRM_DEBUG_KMS("Exiting %s.\n", __func__);
return ret;
}
diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.h b/drivers/gpu/drm/openchrome/openchrome_drv.h
index 641166eed88b..31e5d040ed10 100644
--- a/drivers/gpu/drm/openchrome/openchrome_drv.h
+++ b/drivers/gpu/drm/openchrome/openchrome_drv.h
@@ -451,8 +451,13 @@ 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);
+int openchrome_plane_init(struct openchrome_drm_private *dev_private,
+ struct drm_plane **p_primary,
+ struct drm_plane **p_cursor);
int openchrome_crtc_init(struct openchrome_drm_private *dev_private,
- uint32_t index);
+ struct drm_plane *primary,
+ struct drm_plane *cursor,
+ uint32_t i);
/* encoders */
extern void via_set_sync_polarity(struct drm_encoder *encoder,
More information about the openchrome-devel
mailing list