Skip to content

Commit f46e699

Browse files
committed
Merge tag 'imx-drm-fixes-2015-12-01' of git://git.pengutronix.de/git/pza/linux into drm-fixes
imx-drm crtc, plane, parallel panel, and TV encoder fixes - Use drm_crtc_send_vblank_event to fix per crtc vblank handling - Move the crtc device of_node assignment out of the ipuv3-crtc driver into ipu-common code, where the devices are created. - Fix parallel display support with simple-panels - Remove some unused fields and superfluous checks - Switch to universal planes and add error handling for primary plane creation - Fix module autoload for TV encoder driver * tag 'imx-drm-fixes-2015-12-01' of git://git.pengutronix.de/git/pza/linux: drm: imx: imx-tve: Fix module autoload for OF platform driver drm: imx: convert to drm_crtc_send_vblank_event() GPU-DRM-IMX: Delete an unnecessary check before drm_fbdev_cma_restore_mode() drm/imx: Remove of_node assignment from ipuv3-crtc driver probe gpu: ipu-v3: Assign of_node of child platform devices to corresponding ports gpu: ipu-v3: Remove reg_offset field gpu: ipu-v3: drop unused dmfc field from client platform data drm/imx: parallel-display: allow to determine bus format from the connected panel drm/imx: ipuv3-crtc: Return error if ipu_plane_init() fails for primary plane drm/imx: switch to universal planes
2 parents 00b8307 + 5e4789d commit f46e699

File tree

9 files changed

+70
-89
lines changed

9 files changed

+70
-89
lines changed

drivers/gpu/drm/imx/imx-drm-core.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ static void imx_drm_driver_lastclose(struct drm_device *drm)
6363
#if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER)
6464
struct imx_drm_device *imxdrm = drm->dev_private;
6565

66-
if (imxdrm->fbhelper)
67-
drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
66+
drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
6867
#endif
6968
}
7069

@@ -340,7 +339,7 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags)
340339
* imx_drm_add_crtc - add a new crtc
341340
*/
342341
int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
343-
struct imx_drm_crtc **new_crtc,
342+
struct imx_drm_crtc **new_crtc, struct drm_plane *primary_plane,
344343
const struct imx_drm_crtc_helper_funcs *imx_drm_helper_funcs,
345344
struct device_node *port)
346345
{
@@ -379,7 +378,7 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
379378
drm_crtc_helper_add(crtc,
380379
imx_drm_crtc->imx_drm_helper_funcs.crtc_helper_funcs);
381380

382-
drm_crtc_init(drm, crtc,
381+
drm_crtc_init_with_planes(drm, crtc, primary_plane, NULL,
383382
imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs);
384383

385384
return 0;

drivers/gpu/drm/imx/imx-drm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ struct drm_display_mode;
99
struct drm_encoder;
1010
struct drm_fbdev_cma;
1111
struct drm_framebuffer;
12+
struct drm_plane;
1213
struct imx_drm_crtc;
1314
struct platform_device;
1415

@@ -24,7 +25,7 @@ struct imx_drm_crtc_helper_funcs {
2425
};
2526

2627
int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
27-
struct imx_drm_crtc **new_crtc,
28+
struct imx_drm_crtc **new_crtc, struct drm_plane *primary_plane,
2829
const struct imx_drm_crtc_helper_funcs *imx_helper_funcs,
2930
struct device_node *port);
3031
int imx_drm_remove_crtc(struct imx_drm_crtc *);

drivers/gpu/drm/imx/imx-tve.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ static const struct of_device_id imx_tve_dt_ids[] = {
721721
{ .compatible = "fsl,imx53-tve", },
722722
{ /* sentinel */ }
723723
};
724+
MODULE_DEVICE_TABLE(of, imx_tve_dt_ids);
724725

725726
static struct platform_driver imx_tve_driver = {
726727
.probe = imx_tve_probe,

drivers/gpu/drm/imx/ipuv3-crtc.c

Lines changed: 17 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ static void ipu_crtc_handle_pageflip(struct ipu_crtc *ipu_crtc)
212212

213213
spin_lock_irqsave(&drm->event_lock, flags);
214214
if (ipu_crtc->page_flip_event)
215-
drm_send_vblank_event(drm, -1, ipu_crtc->page_flip_event);
215+
drm_crtc_send_vblank_event(&ipu_crtc->base,
216+
ipu_crtc->page_flip_event);
216217
ipu_crtc->page_flip_event = NULL;
217218
imx_drm_crtc_vblank_put(ipu_crtc->imx_crtc);
218219
spin_unlock_irqrestore(&drm->event_lock, flags);
@@ -349,7 +350,6 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,
349350
struct ipu_soc *ipu = dev_get_drvdata(ipu_crtc->dev->parent);
350351
int dp = -EINVAL;
351352
int ret;
352-
int id;
353353

354354
ret = ipu_get_resources(ipu_crtc, pdata);
355355
if (ret) {
@@ -358,18 +358,23 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,
358358
return ret;
359359
}
360360

361+
if (pdata->dp >= 0)
362+
dp = IPU_DP_FLOW_SYNC_BG;
363+
ipu_crtc->plane[0] = ipu_plane_init(drm, ipu, pdata->dma[0], dp, 0,
364+
DRM_PLANE_TYPE_PRIMARY);
365+
if (IS_ERR(ipu_crtc->plane[0])) {
366+
ret = PTR_ERR(ipu_crtc->plane[0]);
367+
goto err_put_resources;
368+
}
369+
361370
ret = imx_drm_add_crtc(drm, &ipu_crtc->base, &ipu_crtc->imx_crtc,
362-
&ipu_crtc_helper_funcs, ipu_crtc->dev->of_node);
371+
&ipu_crtc->plane[0]->base, &ipu_crtc_helper_funcs,
372+
ipu_crtc->dev->of_node);
363373
if (ret) {
364374
dev_err(ipu_crtc->dev, "adding crtc failed with %d.\n", ret);
365375
goto err_put_resources;
366376
}
367377

368-
if (pdata->dp >= 0)
369-
dp = IPU_DP_FLOW_SYNC_BG;
370-
id = imx_drm_crtc_id(ipu_crtc->imx_crtc);
371-
ipu_crtc->plane[0] = ipu_plane_init(ipu_crtc->base.dev, ipu,
372-
pdata->dma[0], dp, BIT(id), true);
373378
ret = ipu_plane_get_resources(ipu_crtc->plane[0]);
374379
if (ret) {
375380
dev_err(ipu_crtc->dev, "getting plane 0 resources failed with %d.\n",
@@ -379,10 +384,10 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,
379384

380385
/* If this crtc is using the DP, add an overlay plane */
381386
if (pdata->dp >= 0 && pdata->dma[1] > 0) {
382-
ipu_crtc->plane[1] = ipu_plane_init(ipu_crtc->base.dev, ipu,
383-
pdata->dma[1],
384-
IPU_DP_FLOW_SYNC_FG,
385-
BIT(id), false);
387+
ipu_crtc->plane[1] = ipu_plane_init(drm, ipu, pdata->dma[1],
388+
IPU_DP_FLOW_SYNC_FG,
389+
drm_crtc_mask(&ipu_crtc->base),
390+
DRM_PLANE_TYPE_OVERLAY);
386391
if (IS_ERR(ipu_crtc->plane[1]))
387392
ipu_crtc->plane[1] = NULL;
388393
}
@@ -407,28 +412,6 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,
407412
return ret;
408413
}
409414

410-
static struct device_node *ipu_drm_get_port_by_id(struct device_node *parent,
411-
int port_id)
412-
{
413-
struct device_node *port;
414-
int id, ret;
415-
416-
port = of_get_child_by_name(parent, "port");
417-
while (port) {
418-
ret = of_property_read_u32(port, "reg", &id);
419-
if (!ret && id == port_id)
420-
return port;
421-
422-
do {
423-
port = of_get_next_child(parent, port);
424-
if (!port)
425-
return NULL;
426-
} while (of_node_cmp(port->name, "port"));
427-
}
428-
429-
return NULL;
430-
}
431-
432415
static int ipu_drm_bind(struct device *dev, struct device *master, void *data)
433416
{
434417
struct ipu_client_platformdata *pdata = dev->platform_data;
@@ -470,23 +453,11 @@ static const struct component_ops ipu_crtc_ops = {
470453
static int ipu_drm_probe(struct platform_device *pdev)
471454
{
472455
struct device *dev = &pdev->dev;
473-
struct ipu_client_platformdata *pdata = dev->platform_data;
474456
int ret;
475457

476458
if (!dev->platform_data)
477459
return -EINVAL;
478460

479-
if (!dev->of_node) {
480-
/* Associate crtc device with the corresponding DI port node */
481-
dev->of_node = ipu_drm_get_port_by_id(dev->parent->of_node,
482-
pdata->di + 2);
483-
if (!dev->of_node) {
484-
dev_err(dev, "missing port@%d node in %s\n",
485-
pdata->di + 2, dev->parent->of_node->full_name);
486-
return -ENODEV;
487-
}
488-
}
489-
490461
ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
491462
if (ret)
492463
return ret;

drivers/gpu/drm/imx/ipuv3-plane.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ static struct drm_plane_funcs ipu_plane_funcs = {
381381

382382
struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
383383
int dma, int dp, unsigned int possible_crtcs,
384-
bool priv)
384+
enum drm_plane_type type)
385385
{
386386
struct ipu_plane *ipu_plane;
387387
int ret;
@@ -399,10 +399,9 @@ struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
399399
ipu_plane->dma = dma;
400400
ipu_plane->dp_flow = dp;
401401

402-
ret = drm_plane_init(dev, &ipu_plane->base, possible_crtcs,
403-
&ipu_plane_funcs, ipu_plane_formats,
404-
ARRAY_SIZE(ipu_plane_formats),
405-
priv);
402+
ret = drm_universal_plane_init(dev, &ipu_plane->base, possible_crtcs,
403+
&ipu_plane_funcs, ipu_plane_formats,
404+
ARRAY_SIZE(ipu_plane_formats), type);
406405
if (ret) {
407406
DRM_ERROR("failed to initialize plane\n");
408407
kfree(ipu_plane);

drivers/gpu/drm/imx/ipuv3-plane.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct ipu_plane {
3434

3535
struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
3636
int dma, int dp, unsigned int possible_crtcs,
37-
bool priv);
37+
enum drm_plane_type type);
3838

3939
/* Init IDMAC, DMFC, DP */
4040
int ipu_plane_mode_set(struct ipu_plane *plane, struct drm_crtc *crtc,

drivers/gpu/drm/imx/parallel-display.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
5454

5555
if (imxpd->panel && imxpd->panel->funcs &&
5656
imxpd->panel->funcs->get_modes) {
57+
struct drm_display_info *di = &connector->display_info;
58+
5759
num_modes = imxpd->panel->funcs->get_modes(imxpd->panel);
60+
if (!imxpd->bus_format && di->num_bus_formats)
61+
imxpd->bus_format = di->bus_formats[0];
5862
if (num_modes > 0)
5963
return num_modes;
6064
}

drivers/gpu/ipu-v3/ipu-common.c

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/irqchip/chained_irq.h>
2929
#include <linux/irqdomain.h>
3030
#include <linux/of_device.h>
31+
#include <linux/of_graph.h>
3132

3233
#include <drm/drm_fourcc.h>
3334

@@ -993,11 +994,25 @@ static void platform_device_unregister_children(struct platform_device *pdev)
993994
struct ipu_platform_reg {
994995
struct ipu_client_platformdata pdata;
995996
const char *name;
996-
int reg_offset;
997997
};
998998

999+
/* These must be in the order of the corresponding device tree port nodes */
9991000
static const struct ipu_platform_reg client_reg[] = {
10001001
{
1002+
.pdata = {
1003+
.csi = 0,
1004+
.dma[0] = IPUV3_CHANNEL_CSI0,
1005+
.dma[1] = -EINVAL,
1006+
},
1007+
.name = "imx-ipuv3-camera",
1008+
}, {
1009+
.pdata = {
1010+
.csi = 1,
1011+
.dma[0] = IPUV3_CHANNEL_CSI1,
1012+
.dma[1] = -EINVAL,
1013+
},
1014+
.name = "imx-ipuv3-camera",
1015+
}, {
10011016
.pdata = {
10021017
.di = 0,
10031018
.dc = 5,
@@ -1015,22 +1030,6 @@ static const struct ipu_platform_reg client_reg[] = {
10151030
.dma[1] = -EINVAL,
10161031
},
10171032
.name = "imx-ipuv3-crtc",
1018-
}, {
1019-
.pdata = {
1020-
.csi = 0,
1021-
.dma[0] = IPUV3_CHANNEL_CSI0,
1022-
.dma[1] = -EINVAL,
1023-
},
1024-
.reg_offset = IPU_CM_CSI0_REG_OFS,
1025-
.name = "imx-ipuv3-camera",
1026-
}, {
1027-
.pdata = {
1028-
.csi = 1,
1029-
.dma[0] = IPUV3_CHANNEL_CSI1,
1030-
.dma[1] = -EINVAL,
1031-
},
1032-
.reg_offset = IPU_CM_CSI1_REG_OFS,
1033-
.name = "imx-ipuv3-camera",
10341033
},
10351034
};
10361035

@@ -1051,22 +1050,30 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base)
10511050
for (i = 0; i < ARRAY_SIZE(client_reg); i++) {
10521051
const struct ipu_platform_reg *reg = &client_reg[i];
10531052
struct platform_device *pdev;
1054-
struct resource res;
1055-
1056-
if (reg->reg_offset) {
1057-
memset(&res, 0, sizeof(res));
1058-
res.flags = IORESOURCE_MEM;
1059-
res.start = ipu_base + ipu->devtype->cm_ofs + reg->reg_offset;
1060-
res.end = res.start + PAGE_SIZE - 1;
1061-
pdev = platform_device_register_resndata(dev, reg->name,
1062-
id++, &res, 1, &reg->pdata, sizeof(reg->pdata));
1063-
} else {
1064-
pdev = platform_device_register_data(dev, reg->name,
1065-
id++, &reg->pdata, sizeof(reg->pdata));
1053+
1054+
pdev = platform_device_alloc(reg->name, id++);
1055+
if (!pdev) {
1056+
ret = -ENOMEM;
1057+
goto err_register;
1058+
}
1059+
1060+
pdev->dev.parent = dev;
1061+
1062+
/* Associate subdevice with the corresponding port node */
1063+
pdev->dev.of_node = of_graph_get_port_by_id(dev->of_node, i);
1064+
if (!pdev->dev.of_node) {
1065+
dev_err(dev, "missing port@%d node in %s\n", i,
1066+
dev->of_node->full_name);
1067+
ret = -ENODEV;
1068+
goto err_register;
10661069
}
10671070

1068-
if (IS_ERR(pdev)) {
1069-
ret = PTR_ERR(pdev);
1071+
ret = platform_device_add_data(pdev, &reg->pdata,
1072+
sizeof(reg->pdata));
1073+
if (!ret)
1074+
ret = platform_device_add(pdev);
1075+
if (ret) {
1076+
platform_device_put(pdev);
10701077
goto err_register;
10711078
}
10721079
}

include/video/imx-ipu-v3.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ struct ipu_client_platformdata {
343343
int di;
344344
int dc;
345345
int dp;
346-
int dmfc;
347346
int dma[2];
348347
};
349348

0 commit comments

Comments
 (0)