Commit 2b54f781 authored by Dave Airlie's avatar Dave Airlie

Merge branch 'drm/shmob' of git://linuxtv.org/pinchartl/fbdev into drm-next

Fixes for shmob + prime support

* 'drm/shmob' of git://linuxtv.org/pinchartl/fbdev:
  drm/shmobile: Enable compilation on all ARM platforms
  drm/shmobile: Add DRM PRIME support
  drm/shmobile: Use devm_* managed functions
  drm/shmobile: Minor typo fix in debug message
parents 4bf8e196 227c1fb2
config DRM_SHMOBILE config DRM_SHMOBILE
tristate "DRM Support for SH Mobile" tristate "DRM Support for SH Mobile"
depends on DRM && (SUPERH || ARCH_SHMOBILE) depends on DRM && (ARM || SUPERH)
select DRM_KMS_HELPER select DRM_KMS_HELPER
select DRM_KMS_CMA_HELPER select DRM_KMS_CMA_HELPER
select DRM_GEM_CMA_HELPER select DRM_GEM_CMA_HELPER
......
...@@ -90,7 +90,7 @@ static int shmob_drm_setup_clocks(struct shmob_drm_device *sdev, ...@@ -90,7 +90,7 @@ static int shmob_drm_setup_clocks(struct shmob_drm_device *sdev,
return -EINVAL; return -EINVAL;
} }
clk = clk_get(sdev->dev, clkname); clk = devm_clk_get(sdev->dev, clkname);
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
dev_err(sdev->dev, "cannot get dot clock %s\n", clkname); dev_err(sdev->dev, "cannot get dot clock %s\n", clkname);
return PTR_ERR(clk); return PTR_ERR(clk);
...@@ -106,21 +106,12 @@ static int shmob_drm_setup_clocks(struct shmob_drm_device *sdev, ...@@ -106,21 +106,12 @@ static int shmob_drm_setup_clocks(struct shmob_drm_device *sdev,
static int shmob_drm_unload(struct drm_device *dev) static int shmob_drm_unload(struct drm_device *dev)
{ {
struct shmob_drm_device *sdev = dev->dev_private;
drm_kms_helper_poll_fini(dev); drm_kms_helper_poll_fini(dev);
drm_mode_config_cleanup(dev); drm_mode_config_cleanup(dev);
drm_vblank_cleanup(dev); drm_vblank_cleanup(dev);
drm_irq_uninstall(dev); drm_irq_uninstall(dev);
if (sdev->clock)
clk_put(sdev->clock);
if (sdev->mmio)
iounmap(sdev->mmio);
dev->dev_private = NULL; dev->dev_private = NULL;
kfree(sdev);
return 0; return 0;
} }
...@@ -139,7 +130,7 @@ static int shmob_drm_load(struct drm_device *dev, unsigned long flags) ...@@ -139,7 +130,7 @@ static int shmob_drm_load(struct drm_device *dev, unsigned long flags)
return -EINVAL; return -EINVAL;
} }
sdev = kzalloc(sizeof(*sdev), GFP_KERNEL); sdev = devm_kzalloc(&pdev->dev, sizeof(*sdev), GFP_KERNEL);
if (sdev == NULL) { if (sdev == NULL) {
dev_err(dev->dev, "failed to allocate private data\n"); dev_err(dev->dev, "failed to allocate private data\n");
return -ENOMEM; return -ENOMEM;
...@@ -156,29 +147,28 @@ static int shmob_drm_load(struct drm_device *dev, unsigned long flags) ...@@ -156,29 +147,28 @@ static int shmob_drm_load(struct drm_device *dev, unsigned long flags)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) { if (res == NULL) {
dev_err(&pdev->dev, "failed to get memory resource\n"); dev_err(&pdev->dev, "failed to get memory resource\n");
ret = -EINVAL; return -EINVAL;
goto done;
} }
sdev->mmio = ioremap_nocache(res->start, resource_size(res)); sdev->mmio = devm_ioremap_nocache(&pdev->dev, res->start,
resource_size(res));
if (sdev->mmio == NULL) { if (sdev->mmio == NULL) {
dev_err(&pdev->dev, "failed to remap memory resource\n"); dev_err(&pdev->dev, "failed to remap memory resource\n");
ret = -ENOMEM; return -ENOMEM;
goto done;
} }
ret = shmob_drm_setup_clocks(sdev, pdata->clk_source); ret = shmob_drm_setup_clocks(sdev, pdata->clk_source);
if (ret < 0) if (ret < 0)
goto done; return ret;
ret = shmob_drm_init_interface(sdev); ret = shmob_drm_init_interface(sdev);
if (ret < 0) if (ret < 0)
goto done; return ret;
ret = shmob_drm_modeset_init(sdev); ret = shmob_drm_modeset_init(sdev);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "failed to initialize mode setting\n"); dev_err(&pdev->dev, "failed to initialize mode setting\n");
goto done; return ret;
} }
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
...@@ -273,7 +263,8 @@ static const struct file_operations shmob_drm_fops = { ...@@ -273,7 +263,8 @@ static const struct file_operations shmob_drm_fops = {
}; };
static struct drm_driver shmob_drm_driver = { static struct drm_driver shmob_drm_driver = {
.driver_features = DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET, .driver_features = DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET
| DRIVER_PRIME,
.load = shmob_drm_load, .load = shmob_drm_load,
.unload = shmob_drm_unload, .unload = shmob_drm_unload,
.preclose = shmob_drm_preclose, .preclose = shmob_drm_preclose,
...@@ -283,6 +274,10 @@ static struct drm_driver shmob_drm_driver = { ...@@ -283,6 +274,10 @@ static struct drm_driver shmob_drm_driver = {
.disable_vblank = shmob_drm_disable_vblank, .disable_vblank = shmob_drm_disable_vblank,
.gem_free_object = drm_gem_cma_free_object, .gem_free_object = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops, .gem_vm_ops = &drm_gem_cma_vm_ops,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_import = drm_gem_cma_dmabuf_import,
.gem_prime_export = drm_gem_cma_dmabuf_export,
.dumb_create = drm_gem_cma_dumb_create, .dumb_create = drm_gem_cma_dumb_create,
.dumb_map_offset = drm_gem_cma_dumb_map_offset, .dumb_map_offset = drm_gem_cma_dumb_map_offset,
.dumb_destroy = drm_gem_cma_dumb_destroy, .dumb_destroy = drm_gem_cma_dumb_destroy,
......
...@@ -116,7 +116,7 @@ shmob_drm_fb_create(struct drm_device *dev, struct drm_file *file_priv, ...@@ -116,7 +116,7 @@ shmob_drm_fb_create(struct drm_device *dev, struct drm_file *file_priv,
} }
if (mode_cmd->pitches[0] & 7 || mode_cmd->pitches[0] >= 65536) { if (mode_cmd->pitches[0] & 7 || mode_cmd->pitches[0] >= 65536) {
dev_dbg(dev->dev, "valid pitch value %u\n", dev_dbg(dev->dev, "invalid pitch value %u\n",
mode_cmd->pitches[0]); mode_cmd->pitches[0]);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
......
...@@ -221,11 +221,8 @@ static int shmob_drm_plane_disable(struct drm_plane *plane) ...@@ -221,11 +221,8 @@ static int shmob_drm_plane_disable(struct drm_plane *plane)
static void shmob_drm_plane_destroy(struct drm_plane *plane) static void shmob_drm_plane_destroy(struct drm_plane *plane)
{ {
struct shmob_drm_plane *splane = to_shmob_plane(plane);
shmob_drm_plane_disable(plane); shmob_drm_plane_disable(plane);
drm_plane_cleanup(plane); drm_plane_cleanup(plane);
kfree(splane);
} }
static const struct drm_plane_funcs shmob_drm_plane_funcs = { static const struct drm_plane_funcs shmob_drm_plane_funcs = {
...@@ -251,7 +248,7 @@ int shmob_drm_plane_create(struct shmob_drm_device *sdev, unsigned int index) ...@@ -251,7 +248,7 @@ int shmob_drm_plane_create(struct shmob_drm_device *sdev, unsigned int index)
struct shmob_drm_plane *splane; struct shmob_drm_plane *splane;
int ret; int ret;
splane = kzalloc(sizeof(*splane), GFP_KERNEL); splane = devm_kzalloc(sdev->dev, sizeof(*splane), GFP_KERNEL);
if (splane == NULL) if (splane == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -261,8 +258,6 @@ int shmob_drm_plane_create(struct shmob_drm_device *sdev, unsigned int index) ...@@ -261,8 +258,6 @@ int shmob_drm_plane_create(struct shmob_drm_device *sdev, unsigned int index)
ret = drm_plane_init(sdev->ddev, &splane->plane, 1, ret = drm_plane_init(sdev->ddev, &splane->plane, 1,
&shmob_drm_plane_funcs, formats, &shmob_drm_plane_funcs, formats,
ARRAY_SIZE(formats), false); ARRAY_SIZE(formats), false);
if (ret < 0)
kfree(splane);
return ret; return ret;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment