diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-04-22 10:24:03 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-07-03 11:24:48 -0400 |
commit | 42e62ba7a484e12a77b9e330a29bbf7c99d3e60e (patch) | |
tree | d3a9dbd2ed7cd157d365ee214d87ca1e08f06749 | |
parent | 3ecea269959afaae50b001deb294cfb9539dbea3 (diff) |
drm/armada: make variant a CRTC thing
Move the variant pointer into the armada_crtc structure, and update for
the resulting changes.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | drivers/gpu/drm/armada/armada_510.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/armada/armada_crtc.c | 27 | ||||
-rw-r--r-- | drivers/gpu/drm/armada/armada_crtc.h | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/armada/armada_drm.h | 9 | ||||
-rw-r--r-- | drivers/gpu/drm/armada/armada_drv.c | 5 |
5 files changed, 25 insertions, 25 deletions
diff --git a/drivers/gpu/drm/armada/armada_510.c b/drivers/gpu/drm/armada/armada_510.c index a9dabcaef92e..1bcf1a8c1915 100644 --- a/drivers/gpu/drm/armada/armada_510.c +++ b/drivers/gpu/drm/armada/armada_510.c | |||
@@ -79,6 +79,6 @@ static int armada510_crtc_compute_clock(struct armada_crtc *dcrtc, | |||
79 | const struct armada_variant armada510_ops = { | 79 | const struct armada_variant armada510_ops = { |
80 | .has_spu_adv_reg = true, | 80 | .has_spu_adv_reg = true, |
81 | .spu_adv_reg = ADV_HWC32ENABLE | ADV_HWC32ARGB | ADV_HWC32BLEND, | 81 | .spu_adv_reg = ADV_HWC32ENABLE | ADV_HWC32ARGB | ADV_HWC32BLEND, |
82 | .crtc_init = armada510_crtc_init, | 82 | .init = armada510_crtc_init, |
83 | .crtc_compute_clock = armada510_crtc_compute_clock, | 83 | .compute_clock = armada510_crtc_compute_clock, |
84 | }; | 84 | }; |
diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c index 3adddabc3626..afa497489000 100644 --- a/drivers/gpu/drm/armada/armada_crtc.c +++ b/drivers/gpu/drm/armada/armada_crtc.c | |||
@@ -332,17 +332,16 @@ static void armada_drm_crtc_commit(struct drm_crtc *crtc) | |||
332 | static bool armada_drm_crtc_mode_fixup(struct drm_crtc *crtc, | 332 | static bool armada_drm_crtc_mode_fixup(struct drm_crtc *crtc, |
333 | const struct drm_display_mode *mode, struct drm_display_mode *adj) | 333 | const struct drm_display_mode *mode, struct drm_display_mode *adj) |
334 | { | 334 | { |
335 | struct armada_private *priv = crtc->dev->dev_private; | ||
336 | struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc); | 335 | struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc); |
337 | int ret; | 336 | int ret; |
338 | 337 | ||
339 | /* We can't do interlaced modes if we don't have the SPU_ADV_REG */ | 338 | /* We can't do interlaced modes if we don't have the SPU_ADV_REG */ |
340 | if (!priv->variant->has_spu_adv_reg && | 339 | if (!dcrtc->variant->has_spu_adv_reg && |
341 | adj->flags & DRM_MODE_FLAG_INTERLACE) | 340 | adj->flags & DRM_MODE_FLAG_INTERLACE) |
342 | return false; | 341 | return false; |
343 | 342 | ||
344 | /* Check whether the display mode is possible */ | 343 | /* Check whether the display mode is possible */ |
345 | ret = priv->variant->crtc_compute_clock(dcrtc, adj, NULL); | 344 | ret = dcrtc->variant->compute_clock(dcrtc, adj, NULL); |
346 | if (ret) | 345 | if (ret) |
347 | return false; | 346 | return false; |
348 | 347 | ||
@@ -491,7 +490,6 @@ static int armada_drm_crtc_mode_set(struct drm_crtc *crtc, | |||
491 | struct drm_display_mode *mode, struct drm_display_mode *adj, | 490 | struct drm_display_mode *mode, struct drm_display_mode *adj, |
492 | int x, int y, struct drm_framebuffer *old_fb) | 491 | int x, int y, struct drm_framebuffer *old_fb) |
493 | { | 492 | { |
494 | struct armada_private *priv = crtc->dev->dev_private; | ||
495 | struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc); | 493 | struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc); |
496 | struct armada_regs regs[17]; | 494 | struct armada_regs regs[17]; |
497 | uint32_t lm, rm, tm, bm, val, sclk; | 495 | uint32_t lm, rm, tm, bm, val, sclk; |
@@ -536,7 +534,7 @@ static int armada_drm_crtc_mode_set(struct drm_crtc *crtc, | |||
536 | } | 534 | } |
537 | 535 | ||
538 | /* Now compute the divider for real */ | 536 | /* Now compute the divider for real */ |
539 | priv->variant->crtc_compute_clock(dcrtc, adj, &sclk); | 537 | dcrtc->variant->compute_clock(dcrtc, adj, &sclk); |
540 | 538 | ||
541 | /* Ensure graphic fifo is enabled */ | 539 | /* Ensure graphic fifo is enabled */ |
542 | armada_reg_queue_mod(regs, i, 0, CFG_PDWN64x66, LCD_SPU_SRAM_PARA1); | 540 | armada_reg_queue_mod(regs, i, 0, CFG_PDWN64x66, LCD_SPU_SRAM_PARA1); |
@@ -558,7 +556,7 @@ static int armada_drm_crtc_mode_set(struct drm_crtc *crtc, | |||
558 | dcrtc->v[1].spu_v_porch = tm << 16 | bm; | 556 | dcrtc->v[1].spu_v_porch = tm << 16 | bm; |
559 | val = adj->crtc_hsync_start; | 557 | val = adj->crtc_hsync_start; |
560 | dcrtc->v[1].spu_adv_reg = val << 20 | val | ADV_VSYNCOFFEN | | 558 | dcrtc->v[1].spu_adv_reg = val << 20 | val | ADV_VSYNCOFFEN | |
561 | priv->variant->spu_adv_reg; | 559 | dcrtc->variant->spu_adv_reg; |
562 | 560 | ||
563 | if (interlaced) { | 561 | if (interlaced) { |
564 | /* Odd interlaced frame */ | 562 | /* Odd interlaced frame */ |
@@ -567,7 +565,7 @@ static int armada_drm_crtc_mode_set(struct drm_crtc *crtc, | |||
567 | dcrtc->v[0].spu_v_porch = dcrtc->v[1].spu_v_porch + 1; | 565 | dcrtc->v[0].spu_v_porch = dcrtc->v[1].spu_v_porch + 1; |
568 | val = adj->crtc_hsync_start - adj->crtc_htotal / 2; | 566 | val = adj->crtc_hsync_start - adj->crtc_htotal / 2; |
569 | dcrtc->v[0].spu_adv_reg = val << 20 | val | ADV_VSYNCOFFEN | | 567 | dcrtc->v[0].spu_adv_reg = val << 20 | val | ADV_VSYNCOFFEN | |
570 | priv->variant->spu_adv_reg; | 568 | dcrtc->variant->spu_adv_reg; |
571 | } else { | 569 | } else { |
572 | dcrtc->v[0] = dcrtc->v[1]; | 570 | dcrtc->v[0] = dcrtc->v[1]; |
573 | } | 571 | } |
@@ -582,7 +580,7 @@ static int armada_drm_crtc_mode_set(struct drm_crtc *crtc, | |||
582 | armada_reg_queue_set(regs, i, dcrtc->v[0].spu_v_h_total, | 580 | armada_reg_queue_set(regs, i, dcrtc->v[0].spu_v_h_total, |
583 | LCD_SPUT_V_H_TOTAL); | 581 | LCD_SPUT_V_H_TOTAL); |
584 | 582 | ||
585 | if (priv->variant->has_spu_adv_reg) { | 583 | if (dcrtc->variant->has_spu_adv_reg) { |
586 | armada_reg_queue_mod(regs, i, dcrtc->v[0].spu_adv_reg, | 584 | armada_reg_queue_mod(regs, i, dcrtc->v[0].spu_adv_reg, |
587 | ADV_VSYNC_L_OFF | ADV_VSYNC_H_OFF | | 585 | ADV_VSYNC_L_OFF | ADV_VSYNC_H_OFF | |
588 | ADV_VSYNCOFFEN, LCD_SPU_ADV_REG); | 586 | ADV_VSYNCOFFEN, LCD_SPU_ADV_REG); |
@@ -826,12 +824,11 @@ static int armada_drm_crtc_cursor_set(struct drm_crtc *crtc, | |||
826 | { | 824 | { |
827 | struct drm_device *dev = crtc->dev; | 825 | struct drm_device *dev = crtc->dev; |
828 | struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc); | 826 | struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc); |
829 | struct armada_private *priv = crtc->dev->dev_private; | ||
830 | struct armada_gem_object *obj = NULL; | 827 | struct armada_gem_object *obj = NULL; |
831 | int ret; | 828 | int ret; |
832 | 829 | ||
833 | /* If no cursor support, replicate drm's return value */ | 830 | /* If no cursor support, replicate drm's return value */ |
834 | if (!priv->variant->has_spu_adv_reg) | 831 | if (!dcrtc->variant->has_spu_adv_reg) |
835 | return -ENXIO; | 832 | return -ENXIO; |
836 | 833 | ||
837 | if (handle && w > 0 && h > 0) { | 834 | if (handle && w > 0 && h > 0) { |
@@ -879,11 +876,10 @@ static int armada_drm_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) | |||
879 | { | 876 | { |
880 | struct drm_device *dev = crtc->dev; | 877 | struct drm_device *dev = crtc->dev; |
881 | struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc); | 878 | struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc); |
882 | struct armada_private *priv = crtc->dev->dev_private; | ||
883 | int ret; | 879 | int ret; |
884 | 880 | ||
885 | /* If no cursor support, replicate drm's return value */ | 881 | /* If no cursor support, replicate drm's return value */ |
886 | if (!priv->variant->has_spu_adv_reg) | 882 | if (!dcrtc->variant->has_spu_adv_reg) |
887 | return -EFAULT; | 883 | return -EFAULT; |
888 | 884 | ||
889 | mutex_lock(&dev->struct_mutex); | 885 | mutex_lock(&dev->struct_mutex); |
@@ -1051,7 +1047,7 @@ static int armada_drm_crtc_create_properties(struct drm_device *dev) | |||
1051 | } | 1047 | } |
1052 | 1048 | ||
1053 | int armada_drm_crtc_create(struct drm_device *dev, struct resource *res, | 1049 | int armada_drm_crtc_create(struct drm_device *dev, struct resource *res, |
1054 | int irq) | 1050 | int irq, const struct armada_variant *variant) |
1055 | { | 1051 | { |
1056 | struct armada_private *priv = dev->dev_private; | 1052 | struct armada_private *priv = dev->dev_private; |
1057 | struct armada_crtc *dcrtc; | 1053 | struct armada_crtc *dcrtc; |
@@ -1074,6 +1070,7 @@ int armada_drm_crtc_create(struct drm_device *dev, struct resource *res, | |||
1074 | return -ENOMEM; | 1070 | return -ENOMEM; |
1075 | } | 1071 | } |
1076 | 1072 | ||
1073 | dcrtc->variant = variant; | ||
1077 | dcrtc->base = base; | 1074 | dcrtc->base = base; |
1078 | dcrtc->num = dev->mode_config.num_crtc; | 1075 | dcrtc->num = dev->mode_config.num_crtc; |
1079 | dcrtc->clk = ERR_PTR(-EINVAL); | 1076 | dcrtc->clk = ERR_PTR(-EINVAL); |
@@ -1107,8 +1104,8 @@ int armada_drm_crtc_create(struct drm_device *dev, struct resource *res, | |||
1107 | return ret; | 1104 | return ret; |
1108 | } | 1105 | } |
1109 | 1106 | ||
1110 | if (priv->variant->crtc_init) { | 1107 | if (dcrtc->variant->init) { |
1111 | ret = priv->variant->crtc_init(dcrtc, dev->dev); | 1108 | ret = dcrtc->variant->init(dcrtc, dev->dev); |
1112 | if (ret) { | 1109 | if (ret) { |
1113 | kfree(dcrtc); | 1110 | kfree(dcrtc); |
1114 | return ret; | 1111 | return ret; |
diff --git a/drivers/gpu/drm/armada/armada_crtc.h b/drivers/gpu/drm/armada/armada_crtc.h index 3f0e70bb2e9c..73efcfcdf814 100644 --- a/drivers/gpu/drm/armada/armada_crtc.h +++ b/drivers/gpu/drm/armada/armada_crtc.h | |||
@@ -32,9 +32,11 @@ struct armada_regs { | |||
32 | armada_reg_queue_mod(_r, _i, 0, 0, ~0) | 32 | armada_reg_queue_mod(_r, _i, 0, 0, ~0) |
33 | 33 | ||
34 | struct armada_frame_work; | 34 | struct armada_frame_work; |
35 | struct armada_variant; | ||
35 | 36 | ||
36 | struct armada_crtc { | 37 | struct armada_crtc { |
37 | struct drm_crtc crtc; | 38 | struct drm_crtc crtc; |
39 | const struct armada_variant *variant; | ||
38 | unsigned num; | 40 | unsigned num; |
39 | void __iomem *base; | 41 | void __iomem *base; |
40 | struct clk *clk; | 42 | struct clk *clk; |
@@ -73,7 +75,8 @@ struct armada_crtc { | |||
73 | }; | 75 | }; |
74 | #define drm_to_armada_crtc(c) container_of(c, struct armada_crtc, crtc) | 76 | #define drm_to_armada_crtc(c) container_of(c, struct armada_crtc, crtc) |
75 | 77 | ||
76 | int armada_drm_crtc_create(struct drm_device *, struct resource *, int); | 78 | int armada_drm_crtc_create(struct drm_device *, struct resource *, int, |
79 | const struct armada_variant *); | ||
77 | void armada_drm_crtc_gamma_set(struct drm_crtc *, u16, u16, u16, int); | 80 | void armada_drm_crtc_gamma_set(struct drm_crtc *, u16, u16, u16, int); |
78 | void armada_drm_crtc_gamma_get(struct drm_crtc *, u16 *, u16 *, u16 *, int); | 81 | void armada_drm_crtc_gamma_get(struct drm_crtc *, u16 *, u16 *, u16 *, int); |
79 | void armada_drm_crtc_disable_irq(struct armada_crtc *, u32); | 82 | void armada_drm_crtc_disable_irq(struct armada_crtc *, u32); |
diff --git a/drivers/gpu/drm/armada/armada_drm.h b/drivers/gpu/drm/armada/armada_drm.h index a5452ae883d1..ea63c6c7c66f 100644 --- a/drivers/gpu/drm/armada/armada_drm.h +++ b/drivers/gpu/drm/armada/armada_drm.h | |||
@@ -61,17 +61,16 @@ struct armada_private; | |||
61 | struct armada_variant { | 61 | struct armada_variant { |
62 | bool has_spu_adv_reg; | 62 | bool has_spu_adv_reg; |
63 | uint32_t spu_adv_reg; | 63 | uint32_t spu_adv_reg; |
64 | int (*crtc_init)(struct armada_crtc *, struct device *); | 64 | int (*init)(struct armada_crtc *, struct device *); |
65 | int (*crtc_compute_clock)(struct armada_crtc *, | 65 | int (*compute_clock)(struct armada_crtc *, |
66 | const struct drm_display_mode *, | 66 | const struct drm_display_mode *, |
67 | uint32_t *); | 67 | uint32_t *); |
68 | }; | 68 | }; |
69 | 69 | ||
70 | /* Variant ops */ | 70 | /* Variant ops */ |
71 | extern const struct armada_variant armada510_ops; | 71 | extern const struct armada_variant armada510_ops; |
72 | 72 | ||
73 | struct armada_private { | 73 | struct armada_private { |
74 | const struct armada_variant *variant; | ||
75 | struct work_struct fb_unref_work; | 74 | struct work_struct fb_unref_work; |
76 | DECLARE_KFIFO(fb_unref, struct drm_framebuffer *, 8); | 75 | DECLARE_KFIFO(fb_unref, struct drm_framebuffer *, 8); |
77 | struct drm_fb_helper *fbdev; | 76 | struct drm_fb_helper *fbdev; |
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index 4939a86a2afc..3995be3c686b 100644 --- a/drivers/gpu/drm/armada/armada_drv.c +++ b/drivers/gpu/drm/armada/armada_drv.c | |||
@@ -85,6 +85,7 @@ void armada_drm_queue_unref_work(struct drm_device *dev, | |||
85 | static int armada_drm_load(struct drm_device *dev, unsigned long flags) | 85 | static int armada_drm_load(struct drm_device *dev, unsigned long flags) |
86 | { | 86 | { |
87 | const struct platform_device_id *id; | 87 | const struct platform_device_id *id; |
88 | const struct armada_variant *variant; | ||
88 | struct armada_private *priv; | 89 | struct armada_private *priv; |
89 | struct resource *res[ARRAY_SIZE(priv->dcrtc)]; | 90 | struct resource *res[ARRAY_SIZE(priv->dcrtc)]; |
90 | struct resource *mem = NULL; | 91 | struct resource *mem = NULL; |
@@ -128,7 +129,7 @@ static int armada_drm_load(struct drm_device *dev, unsigned long flags) | |||
128 | if (!id) | 129 | if (!id) |
129 | return -ENXIO; | 130 | return -ENXIO; |
130 | 131 | ||
131 | priv->variant = (struct armada_variant *)id->driver_data; | 132 | variant = (const struct armada_variant *)id->driver_data; |
132 | 133 | ||
133 | INIT_WORK(&priv->fb_unref_work, armada_drm_unref_work); | 134 | INIT_WORK(&priv->fb_unref_work, armada_drm_unref_work); |
134 | INIT_KFIFO(priv->fb_unref); | 135 | INIT_KFIFO(priv->fb_unref); |
@@ -160,7 +161,7 @@ static int armada_drm_load(struct drm_device *dev, unsigned long flags) | |||
160 | if (irq < 0) | 161 | if (irq < 0) |
161 | goto err_kms; | 162 | goto err_kms; |
162 | 163 | ||
163 | ret = armada_drm_crtc_create(dev, res[n], irq); | 164 | ret = armada_drm_crtc_create(dev, res[n], irq, variant); |
164 | if (ret) | 165 | if (ret) |
165 | goto err_kms; | 166 | goto err_kms; |
166 | } | 167 | } |